[Solved] Assigning an Object variable

Keyboard macros or custom scripts

[Solved] Assigning an Object variable

Postby alanbeban » Sun Oct 22, 2017 3:06 am

I am trying to run the following Sub-procedure with the indicated result

Code: Select all   Expand viewCollapse view
Sub Main
  Dim wb, ws1, cell1 As object

  wb=ThisComponent
  ws1=wb.Sheets.getByIndex(0)
  cell1=ws1.getCellByPosition(2,0)
 
  cell1.SetValue(12)
  msgbox cell1.getValue
 
exit sub


'BASIC runtime error
'Property or method not found: Sheets

What's the problem?
Last edited by Hagar Delest on Fri Nov 24, 2017 9:38 am, edited 2 times in total.
Reason: tagged solved
Open Office macOS Sierra 10.12.6
alanbeban
 
Posts: 4
Joined: Sun Oct 22, 2017 2:57 am

Re: Assigning an Object variable

Postby FJCC » Sun Oct 22, 2017 4:38 am

Your code works for me after I changed "exit sub" to "end sub". What steps are you taking to run the code? Where is the macro stored? In my case, I stored the macro within the Calc document.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7015
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Assigning an Object variable

Postby alanbeban » Sun Oct 22, 2017 5:00 am

I just went back and it runs for me now, too. The exit sub doesn't matter; I had other code following what I posted that had nothing to do with the problem. When I added Option VBASupport 1 at the top of the module (based on some other stuff I had read in this forum), the error message changed to "BASIC error '436' or some such. Now, as I said, it runs error free. Although it's no longer relevant, I have no idea where it's stored--don't even really understand the question. I just opened an Open Office spreadsheet and got to the module through clicking on Tools. Well, live and learn--though I don't know what it is I really learned.

Thanks for responding.
Open Office macOS Sierra 10.12.6
alanbeban
 
Posts: 4
Joined: Sun Oct 22, 2017 2:57 am


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 3 guests