[Solved] Insert table with VFP

Creating a macro - Writing a Script - Using the API

[Solved] Insert table with VFP

Postby SBorshenko » Wed Jun 15, 2016 10:17 am

Good afternoon!
I am programmed in Visual Foxpro.
The program should output the report in OpenOffice Writer.
The report table is present. For its creation, use the code:

Code: Select all   Expand viewCollapse view
oOfcMgr = CreateObject ( "com.sun.star.ServiceManager")
IF TYPE ( 'oOfcMgr') = 'O'
  oDispatcher = oOfcMgr.createInstance ( "com.sun.star.frame.DispatchHelper")
  oDesktop = oOfcMgr.createInstance ( "com.sun.star.frame.Desktop")
  oServiceManager = CREATEOBJECT ( "com.sun.star.ServiceManager")
  DIMENSION args1 [1]
  args1 [1] = oServiceManager.Bridge_GetStruct ( "com.sun.star.beans.PropertyValue")
  args1 [1] .Name = "Hidden"
  args1 [1] .Value = .F.
  COMARRAY (oDesktop, 10)
  oDocument = oDesktop.LoadComponentFromURL ( "private: factory / swriter", "_ blank", 0, @ args1)
  IF TYPE ( 'oDocument') = 'O'
    DIMENSION args2 (4)
    args2 [1] = oServiceManager.Bridge_GetStruct ( "com.sun.star.beans.PropertyValue")
    args2 [1] .Name = "TableName"
    args2 [1] .Value = "Table1"

    args2 [2] = oServiceManager.Bridge_GetStruct ( "com.sun.star.beans.PropertyValue")
    args2 [2] .Name = "Columns"
    args2 [2] .Value = 3

    args2 [3] = oServiceManager.Bridge_GetStruct ( "com.sun.star.beans.PropertyValue")
    args2 [3] .Name = "Rows"
    args2 [3] .Value = 2

    args2 [4] = oServiceManager.Bridge_GetStruct ( "com.sun.star.beans.PropertyValue")
    args2 [4] .Name = "Flags"
    args2 [4] .Value = 9
    
    oDispatcher.executeDispatch (oDocument, ".uno: InsertTable", "", 0, @ args2)
  ENDIF
ENDIF

The last command will generate an error: Type mismatch
I can not understand about what to inadequate type of question? What I do wrong?
Last edited by Hagar Delest on Wed Jun 15, 2016 10:42 pm, edited 2 times in total.
Reason: tagged [Solved].
OpenOffice 4.1.2
Window 7 Ultimate x86
SBorshenko
 
Posts: 2
Joined: Wed Jun 15, 2016 9:45 am

Re: Insert table with VFP

Postby SBorshenko » Wed Jun 15, 2016 12:46 pm

I solved the problem.
The first parameter must be oFrame, where
oFrame = oDocument.getCurrentController (). getFrame ()
i.e
oDispatcher.executeDispatch (oFrame, ".uno: InsertTable", "", 0, @ args2)
it working.
OpenOffice 4.1.2
Window 7 Ultimate x86
SBorshenko
 
Posts: 2
Joined: Wed Jun 15, 2016 9:45 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests