[Solved] Convert VBA to OO Basic

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

[Solved] Convert VBA to OO Basic

Post by grnhorn »

Welcome beginner. Please answer all of the questions below which may provide information necessary to answer your question.
-----------------------------------------------------------------------------------------------------------
Which version of OpenOffice.org are you using? 2.4.1
What Operating System (version) are you using? XP
What is your question or comment?

Can anyone convert the following code from VBA to OO Basic?

ActiveWorkbook.FollowHyperlink Address:="mailto:" + address REM 'address' being the 'SendTo' address.
ActiveWorkbook.FollowHyperlink Address:="http://openoffice.org"

Thanks...
Last edited by grnhorn on Fri Jul 18, 2008 1:29 am, edited 1 time in total.
OOo 2.4.X on Ms Windows XP
User avatar
squenson
Volunteer
Posts: 1885
Joined: Wed Jan 30, 2008 9:21 pm
Location: Lausanne, Switzerland

Re: Convert VBA to OO Basic

Post by squenson »

From the excellent A. Pitonyak's e-book (section 5.33):

Code: Select all

Sub LaunchOutsideFile()
  Dim oSvc as object
  oSvc = createUnoService("com.sun.star.system.SystemShellExecute")

  Rem Example 1 - Launch the default program associated with a file extension:
  ' oSvc.execute(ConvertToUrl("C:\sample.txt"), "", 0)

  Rem Example 2 - Open a Folder:
  ' oSvc.execute(ConvertToUrl("C:\Program Files\OpenOffice.org1.1.0"), "", 0)

  Rem Example 3 - Go to a Web address:
  ' oSvc.execute("http://www.openoffice.org/", "", 0)

  Rem Example 4 - Launch the default Email program:
  ' oSvc.execute("mailto:anonymous@ftp.com", "", 0)

  Rem Example 5 - Launch any program, in this case notepad
  oSvc.execute(ConvertToUrl("C:\windows\notepad.exe"), "", 0)

End Sub
LibreOffice 4.2.3.3. on Ubuntu 14.04
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

[Solved] Convert VBA to OO Basic

Post by grnhorn »

Thanks squenson, it worked,.but a couple of questions, what are the empty set of quotes, in red, for in the following:

Rem Example 3 - Go to a Web address:
' oSvc.execute("http://www.openoffice.org/", "", 0)

Last, if there is an error in the ""http://www.openoffice.org/"", a Windows error is produced: "Window can't find '"http://www.openoffice.org/"'. Make sure you typed the name correctly, and try again. To search for a file, click the Start button, and then click Search." How can this error be trapped?
OOo 2.4.X on Ms Windows XP
User avatar
squenson
Volunteer
Posts: 1885
Joined: Wed Jan 30, 2008 9:21 pm
Location: Lausanne, Switzerland

Re: [Solved] Convert VBA to OO Basic

Post by squenson »

This link and this link should answer your questions.
LibreOffice 4.2.3.3. on Ubuntu 14.04
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: [Solved] Convert VBA to OO Basic

Post by grnhorn »

Thanks squenson. I need to spend some time with this considering the possibilities that are raised. My user name is grnhorn for a reason.
OOo 2.4.X on Ms Windows XP
Post Reply