[Solved] IDE question: running a macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Keith1084
Posts: 2
Joined: Tue Mar 18, 2008 1:43 am

[Solved] IDE question: running a macro

Post by Keith1084 »

Running under Windows XP
Version OOo 2.3

I have this very simple code:

Code: Select all

Sub HelloWorld
Print "Hello, world."
End Sub

Sub HelloAgain
	Dim s As String

rem cursor is positioned here

	s = HelloWorldString()
	MsgBox s
End Sub

Function HelloWorldString() As String
	HelloWorldString = "Hello, again, World"
End Function	
When my cursor is positioned as in the above, and I click the green button to run basic, the first macro "HelloWorld" executes. I can run the "HelloAgain" macro... but only by switching to the spreadsheet and going through all the menu: Tools -> Macro etc.

I want to be able to execute a macro of my choosing from the IDE.

In Excel, using VBA, the macro to execute depends on where the cursor is in the listing.

This shouldn't be so hard!

Keith
Last edited by Keith1084 on Tue Mar 25, 2008 1:16 pm, edited 1 time in total.
QuazzieEvil
Volunteer
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: IDE question: running a macro

Post by QuazzieEvil »

when executing from the IDE, the first code block (func or sub) will be executed. Generally, you will have a sub called main at the top. you then use this sub as a sort of driver to call the other subs/funcs.

Code: Select all

Sub main()
   HelloWorld REM CALL HelloWorld Sub
   HelloAgain REM now call HelloAgain
   REM AND SO FORTH
End Sub
Keith1084
Posts: 2
Joined: Tue Mar 18, 2008 1:43 am

Re: IDE question: running a macro

Post by Keith1084 »

Thanks, QuazzieEvil! That was what I was suspecting, but it never hurts to ask. Guess I got a little spoiled using the Excel IDE; however, I can deal with it. Thanks for the quick reply!!
Post Reply