[Solved] IF formula convert to OpenOffice Basic Macro

Creating a macro - Writing a Script - Using the API

[Solved] IF formula convert to OpenOffice Basic Macro

Postby Delacrasph » Fri Apr 19, 2019 9:26 am

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
Delacrasph
 
Posts: 2
Joined: Fri Apr 19, 2019 9:21 am

Re: If excel formula covert to Openoffice Bsaic Macro

Postby RusselB » Fri Apr 19, 2019 5:15 pm

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 and LibreOffice 6.3.3.2 on Windows 7 Pro & Ultimate
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.
User avatar
RusselB
Moderator
 
Posts: 5601
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: If excel formula covert to Openoffice Bsaic Macro

Postby UnklDonald418 » Fri Apr 19, 2019 6:25 pm

A Star Basic macro would look something like this.
Code: Select all   Expand viewCollapse view
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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1238
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: IF formula convert to OpenOffice Basic Macro

Postby JeJe » Sat Apr 20, 2019 9:33 am

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.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 611
Joined: Wed Mar 09, 2016 2:40 pm

Re: IF formula convert to OpenOffice Basic Macro

Postby Delacrasph » Fri May 03, 2019 4:02 pm

Such a great help! Thank you! :)
OpenOffice 4.0.1
Delacrasph
 
Posts: 2
Joined: Fri Apr 19, 2019 9:21 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests