VBA interoperability in OpenOffice

From Apache OpenOffice Wiki
Revision as of 08:03, 27 April 2012 by Chen Peng (Talk | contribs)

Jump to: navigation, search

VBA is an implementation of Microsoft's Visual Basic language, an event-driven programming language which is built into most Microsoft Office applications. OpenOffice can run Microsoft VBA code natively, though there are some APIs of VBA that are not supported, or are only partially supported.

From OpenOffice 3.0 to Apache OpenOffice 3.4, there are many improvements in VBA interoperability, such as import mechanism, API support and event supports in userform and controls. We will classify VBA interoperability from three aspects:

Import

Now we can import MS Excel 2003 and MS Excel 2007(xlsm/xlsb) with no modification, it includes:

  • Import VBA code in Modules, Dialog and Class Modules.
  • Attach and Enable to Run all the Workbook and Worksheet events.
  • Enable the Whole VBA Runtime Environment.
  • Support to import VBA Userform Controls.
  • Attach and Enable all the Userform Controls events.

VBA APIs and Events

This part lists the kinds of VBA APIs and events in VBA runtime library,Excel document APIs and events and Control APIs and events. They are supported or partially supported in OpenOffice.

  • VBA runtime library, including some VBA basic functions, there are more than 120 APIs:

Abs
Asc
Atn
Beep
CBool
CByte
CCur
CDate
CDbl
CDec
ChDir
ChDrive
Chr
Choose
CInt
CLng
Cos
CreateObject
CSng
CStr
CurDir
CVar
CVErr
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Day
DDEInitiate
DDERequest
DDETerminate
DDEExecute
DDEPoke
Dir
Environ
EOF
Err
Error
Erl
Exp
FileAttr
FileCopy
FileDateTime
FileLen
Fix
Format
FormatDateTime
FreeFile
GetAttr
Hex
Hour
IIf
InputBox
InStr
InStrRev
IsArray
IsDate
IsEmpty
IsError
IsMissing
IsNull
IsNumeric
IsObject
Join
Kill
LCase
Left
Len
Load
Log
Loc
LOF
LTrim
Mid
Minute
MkDir
Month
MonthName
MsgBox
Oct
QBColor
Partition
Randomize
Replace
Reset
RGB
Right
RmDir
Rnd
Round
RTrim
SavePicture
Second
Seek
SetAttr
Sgn
Shell
Sin
Space
Split
Sqr
Str
StrComp
StrConv
String
StrReverse
Switch
Tan
TimeSerial
TimeValue
Trim
TypeName
UCase
Unload
Val
VarType
Wait
Weekday
WeekdayName
Year

  • Excel document APIs and events, which are used to operate the Spreadsheet document and handle the event of document.

Application
Axis
AxisTitle
Axes
Border
Borders
Chart
ChartObject
ChartObjects
ChartTitle
ColorFormat
Comment
Comments
Dialog
Dialogs
FillFormat
Font
FormatCondition
FormatConditions
HPageBreak
HPageBreaks
Interior
LineFormat
Name
Names
OLEObject
OLEObjects
Outline
Pane
PageSetup
PictureFormat
PivotCache
PivotTable
PivotTables
QueryTable
Range
SeriesCollection
Shape
ShapeRange
Shapes
Sheets
Styles
Style
TextFrame
Validation
VPageBreak
VPageBreaks
Window
Workbook
Workbooks
Worksheet
WorksheetFunction
Worksheets

  • Control APIs and events, support APIs and events of some usually used controls:

CheckBox
ComboBox
CommandButton
Control
Controls
Frame
Image
Label
ListBox
MultiPage
OptionButton
Page
Pages
ScrollBar
SpinButton
TextBox
ToggleButton
UserForm

Export

Unfortunately, OpenOffice can't support export VBA back to MS Excel files, so Export may be the important and interesting area in VBA interoperability. It can support aspects such as:

  • Export VBA Macros in Document Objects and Modules
  • Ensure VBA Macros Workable in Excel Files
  • Export VBA Macros of VBA Userform Controls into Excel Files
Personal tools