OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Accessing Windows registry / invoking macro

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
wolfgang
Guest





PostPosted: Tue Feb 24, 2004 9:38 am    Post subject: Accessing Windows registry / invoking macro Reply with quote

Hi!

I would like to access a certain entry in the windows registry out of an OpenOffice Basic macro.
Does anyone know how to do this??

And a second question:
I found out how to activate an instance of openOffice and open a certain OpenOffice Calc file out of my VisualBasic application. I know would like to invoke a macro in the Calc-file out of the VisualBasic application!
-Has anyone come across this requirement before and knows a solution??

Any help would be highly appreciated!

Thanks in advance!

wolfgang
Back to top
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Tue Feb 24, 2004 10:41 am    Post subject: Reply with quote

wolfgang wrote:
would like to access a certain entry in the windows registry out of an OpenOffice Basic macro.


See this....

http://www.oooforum.org/forum/viewtopic.php?t=5918

It is possible to write code in VB, save it as a DLL, register it, and then call it from OOo Basic.

This technique would allow you to do anything Windows specific, such as access the registry. You would distribute your VB-created DLL to your end users who run OOo on Windows, along with an installer. Or give them a document explaining how to use the regsvr32 command.



wolfgang wrote:
I know would like to invoke a macro in the Calc-file out of the VisualBasic application!
-Has anyone come across this requirement before and knows a solution??


Use a macro:/// url via. the Dispatcher
http://www.oooforum.org/forum/viewtopic.php?t=6079


http://www.oooforum.org/forum/viewtopic.php?t=4071
http://www.oooforum.org/forum/viewtopic.php?p=15589#15589
http://www.oooforum.org/forum/viewtopic.php?p=9861#9861
http://www.oooforum.org/forum/viewtopic.php?p=17377#17377
http://www.oooforum.org/forum/viewtopic.php?t=3196
http://www.oooforum.org/forum/viewtopic.php?t=2619
http://www.oooforum.org/forum/viewtopic.php?p=11794#11794

http://www.oooforum.org/forum/viewtopic.php?p=13053#13053

http://www.oooforum.org/forum/viewtopic.php?t=4285

http://www.oooforum.org/forum/viewtopic.php?t=3772

http://www.oooforum.org/forum/viewtopic.php?t=4163

http://www.oooforum.org/forum/viewtopic.php?t=2688

Calling macro in different document, and pass parameter...
http://www.oooforum.org/forum/viewtopic.php?t=5564
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Henrik
OOo Enthusiast
OOo Enthusiast


Joined: 15 Jan 2004
Posts: 118

PostPosted: Tue Feb 24, 2004 2:36 pm    Post subject: Reply with quote

Hi,

Quote:

DannyB wrote:
It is possible to write code in VB, save it as a DLL, register it, and then call it from OOo Basic.

This technique would allow you to do anything Windows specific, such as access the registry.


Just thought I should mention that this is also very possible to do in Python. I know DannyB knows that of course, but after using Python for a while now I like it so much that advocating a bit for the language seemed like the right thing to do Smile

Maybe you already know python, if not here a a couple of links:
www.python.org
http://starship.python.net/crew/mhammond/ # windows extension you'll need to code against the registry.

Henrik
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Feb 25, 2004 8:16 am    Post subject: Reply with quote

Hello!

Thank you very much for for the links to these topics of interest.

Unfortunately I still have some problems, invoking a macro stored in a certain workbook.

Out of my Visual Basic 6 application I open the OpenOffice calc document by:
Set objDocument = objDesktop.loadComponentFromURL("file:///c:/Test/DemoCode.sxc", "_blank", 0, args)
Set Frame = objDocument.getCurrentController().getFrame()

Then I want to call a macro in this document (DemoCode.sxc) and pass a parameter. According to the posts I read on this topic this should work somehow like:
Call dispatcher.executeDispatch(Frame, "macro://DemoCode/Standard.Module1.Hello(myText)", "", 0, args)

Unfortunately the macro is not executed.
Calling the macro works, if I place the macro not in the opened document, but in the "root" for macros (soffice) and then call it like:
Call dispatcher.executeDispatch(Frame, "macro:///Standard.Module1.Hello(MyText)", "", 0, args)

Has anyone an idea what I am doing wrong?

Thanks in advance,
wolfgang
Back to top
wolfo
Newbie
Newbie


Joined: 26 Feb 2004
Posts: 3

PostPosted: Wed Mar 03, 2004 2:57 am    Post subject: Reply with quote

Quote:

Out of my Visual Basic 6 application I open the OpenOffice calc document by:
Set objDocument = objDesktop.loadComponentFromURL("file:///c:/Test/DemoCode.sxc", "_blank", 0, args)


Macros have to be enabled in the opened document. You have to set the MacroExectutionMode by passing the appropriate parameter:
Code:

Dim args(0) As Object
Set args(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
args(0).Name = "MacroExecutionMode"
args(0).Value = 4
Set objDocument = objDesktop.loadComponentFromURL("file:///c:/Test/DemoCode.sxc", "_blank", 0, args())
 


DannyB has posted a link to the description of MacroExecutionMode contants:
http://www.oooforum.org/forum/viewtopic.php?p=16178#16178

I didn't find out how to access the constants in Visual Basic so I used the absolute value.

Opening the document like that makes it possible to call macros in the document out of VB.
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Fri Mar 12, 2004 6:30 pm    Post subject: Reply with quote

Here is a related discussion with a very interesting proposed solution.

http://www.oooforum.org/forum/viewtopic.php?t=6768
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group