[Solved] IF formula convert to OpenOffice Basic Macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Delacrasph
Posts: 2
Joined: Fri Apr 19, 2019 9:21 am

[Solved] IF formula convert to OpenOffice Basic Macro

Post by Delacrasph »

I badly need your help in converting Excel VBA to OpenOffice Basic. I have a deadline and I need to submit it ASAP. Your response will be highly appreciated.

If H8 = 10 then
Copy ‘copy different module
Else
Msgbox “Fill-in all required fields to proceed.”

End If
End Sub
Last edited by Hagar Delest on Fri May 03, 2019 9:44 pm, edited 1 time in total.
Reason: tagged solved
OpenOffice 4.0.1
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: If excel formula covert to Openoffice Bsaic Macro

Post by RusselB »

Welcome to the Forums.
Regretfully I have little knowledge of OpenOffice programming (aka macros), however, I can tell you that this is not a topic to get into with a deadline
Andrew Pitonyak has a number of books (usually in PDF format) that you can download and read. I suggest googling the name along with "OpenOffice Macros"

Some of the helpers here are a lot more experienced with this type of thing, and might provide you with a working code before your deadline, but we cannot be held responsible if you miss your deadline due to waiting for a response or the time taken to research the requirements so that you can write it yourself.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: If excel formula covert to Openoffice Bsaic Macro

Post by UnklDonald418 »

A Star Basic macro would look something like this.

Code: Select all

Sub TestValueInCellH8

  Dim oSheet As Variant
  Dim oCell As Variant

REM when using the OO API, sheet numbers begin with 0
    oSheet = ThisComponent.getSheets().getByIndex(0) 
REM getCellByPosition(nColumn, nRow)   when using the API, row and column numbers begin with 0 
    oCell = oSheet .getCellByPosition(7, 7)   ' cell H8

  If oCell.Value() = 10 then
REM Copy ‘copy different module
  Else
     Msgbox (“Fill-in all required fields to proceed.”,0)     'displays message in a dialog box with just an OK button
  End If 

End Sub
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: IF formula convert to OpenOffice Basic Macro

Post by JeJe »

VBA and OO Basic are mostly the same in terms of their constructs... if then else etc.

The differences are just how documents and cells and so on are referred to.

You may find the macro recorder the quickest way to get some working code. Recording each step at a time can help you cobble together something that does what you want - without necessarily needing to understand the recorded results.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Delacrasph
Posts: 2
Joined: Fri Apr 19, 2019 9:21 am

Re: IF formula convert to OpenOffice Basic Macro

Post by Delacrasph »

Such a great help! Thank you! :)
OpenOffice 4.0.1
Post Reply