Page 1 of 1

[Solved] IF formula convert to OpenOffice Basic Macro

Posted: Fri Apr 19, 2019 9:26 am
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

Re: If excel formula covert to Openoffice Bsaic Macro

Posted: Fri Apr 19, 2019 5:15 pm
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.

Re: If excel formula covert to Openoffice Bsaic Macro

Posted: Fri Apr 19, 2019 6:25 pm
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

Re: IF formula convert to OpenOffice Basic Macro

Posted: Sat Apr 20, 2019 9:33 am
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.

Re: IF formula convert to OpenOffice Basic Macro

Posted: Fri May 03, 2019 4:02 pm
by Delacrasph
Such a great help! Thank you! :)