MS-Word from PB with COM Interface

Share your advanced PureBasic knowledge/code with the community.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

This is really "work in progress". I discovered that specially the Excel resident was considerable smaller than the Word resident. A large number of Interfaces was not generated. I couldn't find out why at first, but then I found that I should generate the whole interface, including IDispatch. I deleted the \GetRefTypeOfImplType and \GetRefTypeInfo functions. When I did that all the missing Interfaces were generated.

I created two new resident files for MSWord and MSExcel. You can find them at the same location.

http://home.planet.nl/~aXend/purebasic/MSWord.zip
http://home.planet.nl/~aXend/purebasic/MSExcel.zip

Good luck and I'm waiting for your comments.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

aXend,

Could you please describe the process for producing these, and make your tools available?

I'd love to have a go at MSXML
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

I'sorry guys (and girls), I had to remove the residents. I discovered some other bugs. :oops:
I'll try to solve it and come back as soon as possible. :(
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

@GedB: I will make the tool available as soon as I have covered all the bugs. I don't think it is a big problem, so you hear from me soon.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

I have added the resident files again, so they're ready for download. See previous links. You can use them with the following code.

Word example

Code: Select all

IncludeFile "Variant_inc.pb"

#CLSCTX_INPROC_SERVER  = 1
#CLSCTX_INPROC_HANDLER = 2
#CLSCTX_LOCAL_SERVER   = 4 
#CLSCTX_REMOTE_SERVER  = 16

#vbNormal = 0

Global oWord.wd_Application
Global oDocs.wdDocuments
Global oDocument.wd_Document
Global oSel.wdSelection

Global None.VARIANT
None\vt    = #VT_ERROR 
None\scode = #DISP_E_PARAMNOTFOUND 

Procedure.s Uni2Ansi(unicodestr.l)
  lenA = WideCharToMultiByte_(#CP_ACP, 0, unicodestr, -1, 0, 0, 0, 0);
  ansistr.s = Space(lenA)
  If (lenA > 0)
    WideCharToMultiByte_(#CP_ACP, 0, unicodestr, -1, @ansistr, lenA, 0, 0);
  EndIf
  ProcedureReturn ansistr
EndProcedure

Procedure.l Ansi2Uni(ansistr.s)
  lenA.l = Len(ansistr)
  lenW = MultiByteToWideChar_(#CP_ACP, 0, ansistr, lenA, 0, 0)
  If (lenW > 0) ; Check whether conversion was successful
    unicodestr = SysAllocStringLen_(0, lenW)
    MultiByteToWideChar_(#CP_ACP, 0, ansistr, lenA, unicodestr, lenW)
    result = unicodestr
    SysFreeString_(unicodestr)
    ProcedureReturn result
  Else 
    ProcedureReturn 0
  EndIf
EndProcedure

;- Start program
OnErrorGoto(?Error)

OleInitialize_(0) 

If CoCreateInstance_(?CLSID_wdApplication,0,#CLSCTX_LOCAL_SERVER,?IID_wdApplication,@oWord)<>0
  MessageRequester("Warning:","Couldn't init oWord",0)
  End
EndIf
Debug oWord
oWord\put_WindowState(#vbNormal)
oWord\put_Height(300)
oWord\put_Width(400)
oWord\put_Left(40)
oWord\put_Top(300)
oWord\put_Caption(Ansi2Uni("Word from PureBasic"))
oWord\put_Statusbar(Ansi2Uni("Date: " + FormatDate("%mm/%dd/%yyyy", Date())))
oWord\put_Visible(#True)
oWord\get_Documents(@oDocs)
Debug oDocs
If oDocs\Add(None, None, None, None, @oDocument) = #S_OK
  oWord\get_Selection(@oSel)  
  oSel\InsertAfter(Ansi2Uni("This is a test"))
    
  Delay(5000) ; Wait for 5 seconds and than quit
  
  oDocument\Close(None, None, None) 
  
EndIf 

;- End of program
Finish:
oWord\Quit(None,None,None)
If oSel
  oSel\Release()
EndIf
If oDocument
  oDocument\Release() 
EndIf
If oDocs
  oDocs\Release()
EndIf
oWord\Release()
OleUninitialize_()

End

;- Error handler
Error:
error.s = Space(500)
error = GetErrorDescription()
errorln.l = GetErrorLineNR()
MessageRequester("Error",Str(errorln)+":"+error,0)
Goto Finish

End 

DataSection
  CLSID_wdApplication:
  Data.l $000209FF
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection

CLSID_ApplicationStr.s="{000209FF-0000-0000-C000-000000000046}"

DataSection
  IID_wdApplication:
  Data.l $00020970
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection

IID__ApplicationStr.s="{00020970-0000-0000-C000-000000000046}"
Excel example: this is a very simple one, I have to work on it further. If any of you have more on this, then post it please.

Code: Select all

IncludeFile "Variant_inc.pb"

#CLSCTX_INPROC_SERVER  = 1
#CLSCTX_INPROC_HANDLER = 2
#CLSCTX_LOCAL_SERVER   = 4 
#CLSCTX_REMOTE_SERVER  = 16

#lcid = 0   ; don't know the exact meaning and value for this, but this works

Global oExcel.xl_Application
Global oWorkbooks.xlWorkbooks
Global oWorkbook.xl_Workbook

Global None.VARIANT
None\vt    = #VT_ERROR 
None\scode = #DISP_E_PARAMNOTFOUND 

Procedure.s Uni2Ansi(unicodestr.l)
  lenA = WideCharToMultiByte_(#CP_ACP, 0, unicodestr, -1, 0, 0, 0, 0);
  ansistr.s = Space(lenA)
  If (lenA > 0)
    WideCharToMultiByte_(#CP_ACP, 0, unicodestr, -1, @ansistr, lenA, 0, 0);
  EndIf
  ProcedureReturn ansistr
EndProcedure

Procedure.l Ansi2Uni(ansistr.s)
  lenA.l = Len(ansistr)
  lenW = MultiByteToWideChar_(#CP_ACP, 0, ansistr, lenA, 0, 0)
  If (lenW > 0) ; Check whether conversion was successful
    unicodestr = SysAllocStringLen_(0, lenW)
    MultiByteToWideChar_(#CP_ACP, 0, ansistr, lenA, unicodestr, lenW)
    result = unicodestr
    SysFreeString_(unicodestr)
    ProcedureReturn result
  Else 
    ProcedureReturn 0
  EndIf
EndProcedure

;- Start program
OnErrorGoto(?Error)

OleInitialize_(0) 

If CoCreateInstance_(?CLSID_xlApplication,0,#CLSCTX_LOCAL_SERVER,?IID_xlApplication,@oExcel)<>0
  MessageRequester("Warning:","Couldn't init oExcel",0)
  End
EndIf
Debug oExcel

oExcel\put_Caption(Ansi2Uni("Excel from PureBasic"))

;Variant as input for put_Visible
input.VARIANT\vt = #VT_BOOL
input\value = #True
oExcel\put_Visible(#lcid,input)

Delay(5000)  ; Wait for 5 seconds

;- End program
Finish:
oExcel\Quit()
oExcel\Release()

OleUninitialize_()

End

;- Error handler
Error:
error.s = Space(500)
error = GetErrorDescription()
errorln.l = GetErrorLineNR()
MessageRequester("Error",Str(errorln)+":"+error,0)
Goto Finish

End

DataSection
  CLSID_xlApplication:      ;{00024500-0000-0000-C000-000000000046}
  Data.l $00024500
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection

DataSection
  IID_xlApplication:        ;{000208D5-0000-0000-C000-000000000046}
  Data.l $000208D5
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

:lol: :lol: :lol: :lol: :lol:
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

aXend,

Right now, I am entereing the new world you created ...

If I am not wrong, the way to install all what you is ie :

- copy Variant_inc.pb, Excel and Word examples in a folder
- copy MSWord.res / MSExcel.res in the residents' Purebasic directory
- Add or make an include of the Variant structure code in the samples

... and then run one of the samples to see what happens.

Both examples seem to run but give an error message "Could not init o???" (??? meaning either Excel and Word)

When using Excel sample, it just return fast to this error message requester.

When using Word sample, it launchs Word and display the error message requester after a while.

I guess this significates it runs almost. But maybe I have a configuration issue I don't understand, or I missed something in your posts.

Does your code (whole files) contain any possible local parameter I did not change by error ? Or maybe the version of MS tools I have has compatibility problems with the interfaces. I am using Microsoft Office 2000 Standard.

Let me know any idea you have ... I still continue to look if I find something further more to run it completely.

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

I would highly recommend to make a fully archive with all your fantastic work, which could be easily tested & used by PB users. :D

Then I would be glad to release it on PureArea.net. Simple to use code snippets for the codearchive is a bit tricky for this topic. :wink:
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

@Andre: Thanks for your comment. I'm still exploring this world too. When I have it under control (more or less) then I will post the results. In the meantime I will post my progression. I can't promise that it is all bugfree. That also counts for the residents. Exploring the typelibs and generating all the interfaces is a hell of a job. If you have any suggestions on it then I hope to hear from you.

@fweil: I'm sorry to hear that the examples don't work for you yet. It might be because you run Office 2000 and I run Office 2003? I also hope you use the right VARIANT structure. I use the one that Fred posted in the previous examples:

Code: Select all

Structure VARIANT 
  vt.w 
  wReserved1.w 
  wReserved2.w    
  wReserved3.w 
  StructureUnion 
    value.l 
    bstrVal.l 
    scode.l 
  EndStructureUnion 
EndStructure 
I also use the constant

Code: Select all

#DISP_E_PARAMNOTFOUND = $80020004
as Fred posted. The Variant_inc file contains all the #VT-constants.
I don't have any suggestions right now. I think Word works because you get a Word window. So I'm surprised you get the message that you can't Init oWord. If that's so, then you wouldn't get a Word window.

I have to admit that for Excel starting a Workbook doesn't work yet, but I will continue on it. I found the meaning of lcid: it's the local settings. I initialize it as follows:

Code: Select all

lcid = GetUserDefaultLCID_()
Let's keep on working on it.
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

aXend,

I checked, and changed the VARIANT structure, as I mixed between the first you proposed and the one of Fred. I also checked other points :

- #DISP_E_PARAMNOTFOUND = $80020004 is defined in the Variant_inc.pb file

- lcid = GetUserDefaultLCID_(), inserted now in the program.

This does not change the behaviour.

I will look further MSDN about possible differencies because I use 2000 and not 2003.

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

I have an idea: it could be the CLSID. You can look in the registry for Excel.Application and see if the CLSID is different from the one I defined. If different, you have to change the Datasection of the CLSID.

For the typelib I used {00020813-0000-0000-C000-000000000046}. Look if you can find this string in the registry. If not, that might give a clue at a different interface description.

Let me know.
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

...,

In my registry the key value you posted is at many much places subitems of Typelib Interface

My value is : 00024500-0000-0000-C000-000000000046

In the main Excel sample code, it is the same I have right now, downloaded from this post.

What the IID is, I am not sure, but in the registry most IID keys I parsed are full 00 s.

I also checked about the MSWord key which corresponds between my registry and the app code.
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

If the CLSID exists and the typelib too, then it should at least be possible to create an instance. I have made the following code, that leaves the resident files alone and pure focus on the creating of the instance. If this doesn't work then you have another problem and I don't know right now what to do about it.

This is the code.

Code: Select all

;- Constants
#CLSCTX_INPROC_SERVER  = 1
#CLSCTX_INPROC_HANDLER = 2
#CLSCTX_LOCAL_SERVER   = 4 
#CLSCTX_REMOTE_SERVER  = 16

Interface Test Extends IDispatch
EndInterface

Global oExcel.Test

;- Start program
OnErrorGoto(?Error)

OleInitialize_(0) 

If CoCreateInstance_(?CLSID_xlApplication,0,#CLSCTX_LOCAL_SERVER,?IID_xlApplication,@oExcel)<>0
  MessageRequester("Warning:","Couldn't init oExcel",0)
  End
EndIf
Debug oExcel

;- End program
Finish:
If oExcel
  oExcel\Release()
EndIf

OleUninitialize_()

End

;- Error handler
Error:
error.s = Space(500)
error   = GetErrorDescription()
MessageRequester("Error", error, 0)
Goto Finish

End

DataSection
  CLSID_xlApplication:      ;{00024500-0000-0000-C000-000000000046}
  Data.l $00024500
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection

DataSection
  IID_xlApplication:        ;{000208D5-0000-0000-C000-000000000046}
  Data.l $000208D5
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
I hope this works, good luck again. :)
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

The following code can be used to obtain the ClsID (the big number) from the Prog ID (the name, Word.Application in this case)

Code: Select all

#PB_Limit_StringLength = 65535 

Procedure.s GetHResultMessage(HResult.l)
  ;Converts a COM HResult value into a more meaningful message. 
  ;Params: 
  ;     HResult.l A HResult value return from a COM call
  
  Message.s = ""
  Select HResult
    Case #S_OK
      Message = "OK"
    Case #CLASS_E_CLASSNOTAVAILABLE
      Message = "Class Not Available"
    Case #E_NOINTERFACE
      Message = "No Interface"
    Case #CO_E_NOTINITIALIZED
      Message = "CO_E_NOTINITIALIZED"
    Case #CO_E_ALREADYINITIALIZED
      Message = "CO_E_ALREADYINITIALIZED"
    Case #CO_E_CANTDETERMINECLASS
      Message = "CO_E_CANTDETERMINECLASS"
    Case #CO_E_CLASSSTRING
      Message = "The registered CLSID for the ProgID is invalid"
    Case #CO_E_IIDSTRING
      Message = "CO_E_IIDSTRING"
    Case #CO_E_APPNOTFOUND
      Message = "CO_E_APPNOTFOUND"
    Case #CO_E_APPSINGLEUSE
      Message = "CO_E_APPSINGLEUSE"
    Case #CO_E_ERRORINAPP
      Message = "CO_E_ERRORINAPP"
    Case #CO_E_DLLNOTFOUND
      Message = "CO_E_DLLNOTFOUND"
    Case #CO_E_ERRORINDLL
      Message = "CO_E_ERRORINDLL"
    Case #CO_E_WRONGOSFORAPP
      Message = "CO_E_WRONGOSFORAPP"
    Case #CO_E_OBJNOTREG
      Message = "CO_E_OBJNOTREG"
    Case #CO_E_OBJISREG
      Message = "CO_E_OBJISREG"
    Case #CO_E_OBJNOTCONNECTED
      Message = "CO_E_OBJNOTCONNECTED"
    Case #CO_E_APPDIDNTREG
      Message = "CO_E_APPDIDNTREG"
    Case #CO_E_RELEASED
      Message = "CO_E_RELEASED"
    Case #REGDB_E_WRITEREGDB 
      Message = "An error occurred writing the CLSID To the registry."
    Case #E_OUTOFMEMORY
      Message = "Out of memory."
    Case #STG_E_INSUFFICIENTMEMORY
      Message = "Out of memory."
    Case #E_INVALIDARG
      Message = "One or more of the arguments is invalid."
    Case #DISP_E_UNKNOWNNAME
      Message = "One Or more of the names could not be found."
    Case #DISP_E_UNKNOWNLCID 
      Message = "The locale identifier (LCID) could not be found in the OLE DLLs."
    Default
      Message = "Error Number: $" + Hex(HResult)
  EndSelect
  
  ProcedureReturn Message
EndProcedure

Procedure AnsiToUnicode(ansi.s) 
  ;Returns the ansi conversion of a unicode string.
  ;Params: 
  ;     ansi.s  The ansi string to convert to unicode
  unilen=Len(ansi)*2+1 
  unicode=SysAllocStringLen_(0,unilen) 
  ;TODO Replace this sysalloc with a Global buffer of something
  MultiByteToWideChar_(#CP_ACP,0,ansi,Len(ansi)+1,unicode,unilen) 
  result=unicode 
  SysFreeString_(unicode)    
  ProcedureReturn result    

;This proc was based on a posting by Paul (http://www.reelmedia.org) on the PB Forum
;http://jconserv.net/purebasic/viewtopic.php?t=8608&highlight=multibytetowidechar
EndProcedure 

Procedure UnicodeLength(*Unicode.l)
;Returns the length of a unicode string.
;Params: 
;           uni.l    A pointer to the unicode string
  length = 0
  char.w = 0
  Repeat
    ;The unicode string has 2 bytes for each character, so we need
    ;to peek at them as words rather than bytes in order to find the 
    ;zero terminator
    char = PeekW(*Unicode + length)
    length = length + 2
  Until char = 0 Or length > #PB_Limit_StringLength

  ProcedureReturn length/2
EndProcedure

Procedure.s UnicodeToAnsi(*Unicode.l) 
;Returns the ansi version of a unicode string
;Params: 
;           uni.l    A pointer to the unicode string
  defaultChar.s = "?"
  usedDefaultChar = 0 
  len = UnicodeLength(*Unicode)
  ansi.s = Space(len)
  WideCharToMultiByte_(#CP_ACP,0,*Unicode,len, @ansi, len, @defaultChar, @usedDefaultChar) 
  ProcedureReturn ansi    
EndProcedure 

Procedure.s ProgIdToCLSID(ProgID.s)
  ;*Result will point to the class id's unicodoe string  
  *Result.l = 0 
  ;Create a memory buffer to store the CLSID in
  guid = AllocateMemory(15)
  ;Load the binary CLSID into our memory buffer
  CLSIDFromProgID_(AnsiToUnicode(ProgID), guid)
  ;convert the binary CLSID into a unicode string
  HResult = StringFromCLSID_(guid, @*Result)
  result.s = ""
  If HResult <> #S_OK
    MessageRequester("Error in ProgIdToClsID()", GetHResultMessage(HResult))
    result = ""
  Else
    ;Convert the unicode string to an ansi string
    result = UnicodeToAnsi(*Result)
  EndIf
  CoTaskMemFree_(*Result) ;Free *Result
  ProcedureReturn result
EndProcedure

ProgId.s = "Word.Application"
MessageRequester(ProgID,ProgIdToCLSID(ProgID))
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

@GedB: Nice work. I'm still improving the interface generator, but I will finish it soon. If you want to use XML you can look at viewtopic.php?t=10900. I've posted code to do transformnode and browse an xml file.

@fweil: I got the Excel Interface to work. There is a problem to pass a VARIANT to the methods in the interface, but I found a workaround. I hope that there will come a solution for this.

This is my code for now:

Code: Select all

IncludeFile "Variant_inc.pb"

#CLSCTX_INPROC_SERVER  = 1
#CLSCTX_INPROC_HANDLER = 2
#CLSCTX_LOCAL_SERVER   = 4 
#CLSCTX_REMOTE_SERVER  = 16

lcid.l = GetUserDefaultLCID_()   ; don't know the exact meaning and value for this, but this works

Interface _Application Extends IDispatch
  get_Application(a.l) ; 
  get_Creator(a.l) ; 
  get_Parent(a.l) ; 
  get_ActiveCell(a.l) ; 
  get_ActiveChart(a.l) ; 
  get_ActiveDialog(a.l) ; 
  get_ActiveMenuBar(a.l) ; 
  get_ActivePrinter(a.l,b.l) ; 
  put_ActivePrinter(a.l,b.l) ; 
  get_ActiveSheet(a.l) ; 
  get_ActiveWindow(a.l) ; 
  get_ActiveWorkbook(a.l) ; 
  get_AddIns(a.l) ; 
  get_Assistant(a.l) ; 
  Calculate(a.l) ; 
  get_Cells(a.l) ; 
  get_Charts(a.l) ; 
  get_Columns(a.l) ; 
  get_CommandBars(a.l) ; 
  get_DDEAppReturnCode(a.l,b.l) ; 
  DDEExecute(a.l,b.l,c.l) ; 
  DDEInitiate(a.l,b.l,c.l,d.l) ; 
  DDEPoke(a.l,b.l,c.l,d.l) ; 
  DDERequest(a.l,b.l,c.l,d.l) ; 
  DDETerminate(a.l,b.l) ; 
  get_DialogSheets(a.l) ; 
  Evaluate(a.l,b.l,c.l) ; 
  _Evaluate(a.l,b.l,c.l) ; 
  ExecuteExcel4Macro(a.l,b.l,c.l) ; 
  Intersect(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l,r.l,s.l,t.l,u.l,v.l,w.l,x.l,y.l,z.l,a.l,b.l,c.l,d.l,e.l,f.l) ; 
  get_MenuBars(a.l) ; 
  get_Modules(a.l) ; 
  get_Names(a.l) ; 
  get_Range(a.l,b.l,c.l) ; 
  get_Rows(a.l) ; 
  Run(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l,r.l,s.l,t.l,u.l,v.l,w.l,x.l,y.l,z.l,a.l,b.l,c.l,d.l,e.l,f.l) ; 
  _Run2(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l,r.l,s.l,t.l,u.l,v.l,w.l,x.l,y.l,z.l,a.l,b.l,c.l,d.l,e.l,f.l,g.l) ; 
  get_Selection(a.l,b.l) ; 
  SendKeys(a.l,b.l,c.l) ; 
  get_Sheets(a.l) ; 
  get_ShortcutMenus(a.l,b.l) ; 
  get_ThisWorkbook(a.l,b.l) ; 
  get_Toolbars(a.l) ; 
  Union(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l,r.l,s.l,t.l,u.l,v.l,w.l,x.l,y.l,z.l,a.l,b.l,c.l,d.l,e.l,f.l) ; 
  get_Windows(a.l) ; 
  get_Workbooks(a.l) ; 
  get_WorksheetFunction(a.l) ; 
  get_Worksheets(a.l) ; 
  get_Excel4IntlMacroSheets(a.l) ; 
  get_Excel4MacroSheets(a.l) ; 
  ActivateMicrosoftApp(a.l,b.l) ; 
  AddChartAutoFormat(a.l,b.l,c.l,d.l) ; 
  AddCustomList(a.l,b.l,c.l) ; 
  get_AlertBeforeOverwriting(a.l,b.l) ; 
  put_AlertBeforeOverwriting(a.l,b.l) ; 
  get_AltStartupPath(a.l,b.l) ; 
  put_AltStartupPath(a.l,b.l) ; 
  get_AskToUpdateLinks(a.l,b.l) ; 
  put_AskToUpdateLinks(a.l,b.l) ; 
  get_EnableAnimations(a.l,b.l) ; 
  put_EnableAnimations(a.l,b.l) ; 
  get_AutoCorrect(a.l) ; 
  get_Build(a.l,b.l) ; 
  get_CalculateBeforeSave(a.l,b.l) ; 
  put_CalculateBeforeSave(a.l,b.l) ; 
  get_Calculation(a.l,b.l) ; 
  put_Calculation(a.l,b.l) ; 
  get_Caller(a.l,b.l,c.l) ; 
  get_CanPlaySounds(a.l,b.l) ; 
  get_CanRecordSounds(a.l,b.l) ; 
  get_Caption(a.l) ; 
  put_Caption(a.l) ; 
  get_CellDragAndDrop(a.l,b.l) ; 
  put_CellDragAndDrop(a.l,b.l) ; 
  CentimetersToPoints(a.l,b.l,c.l) ; 
  CheckSpelling(a.l,b.l,c.l,d.l,e.l) ; 
  get_ClipboardFormats(a.l,b.l,c.l) ; 
  get_DisplayClipboardWindow(a.l,b.l) ; 
  put_DisplayClipboardWindow(a.l,b.l) ; 
  get_ColorButtons(a.l) ; 
  put_ColorButtons(a.l) ; 
  get_CommandUnderlines(a.l,b.l) ; 
  put_CommandUnderlines(a.l,b.l) ; 
  get_ConstrainNumeric(a.l,b.l) ; 
  put_ConstrainNumeric(a.l,b.l) ; 
  ConvertFormula(a.l,b.l,c.l,d.l,e.l,f.l,g.l) ; 
  get_CopyObjectsWithCells(a.l,b.l) ; 
  put_CopyObjectsWithCells(a.l,b.l) ; 
  get_Cursor(a.l,b.l) ; 
  put_Cursor(a.l,b.l) ; 
  get_CustomListCount(a.l,b.l) ; 
  get_CutCopyMode(a.l,b.l) ; 
  put_CutCopyMode(a.l,b.l) ; 
  get_DataEntryMode(a.l,b.l) ; 
  put_DataEntryMode(a.l,b.l) ; 
  Dummy1(a.l,b.l,c.l,d.l,e.l) ; 
  Dummy2(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l) ; 
  Dummy3(a.l) ; 
  Dummy4(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l) ; 
  Dummy5(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l) ; 
  Dummy6(a.l) ; 
  Dummy7(a.l) ; 
  Dummy8(a.l,b.l) ; 
  Dummy9(a.l) ; 
  Dummy10(a.l,b.l) ; 
  Dummy11() ; 
  get__Default(a.l) ; 
  get_DefaultFilePath(a.l,b.l) ; 
  put_DefaultFilePath(a.l,b.l) ; 
  DeleteChartAutoFormat(a.l,b.l) ; 
  DeleteCustomList(a.l,b.l) ; 
  get_Dialogs(a.l) ; 
  get_DisplayAlerts(a.l,b.l) ; 
  put_DisplayAlerts(a.l,b.l) ; 
  get_DisplayFormulaBar(a.l,b.l) ; 
  put_DisplayFormulaBar(a.l,b.l) ; 
  get_DisplayFullScreen(a.l,b.l) ; 
  put_DisplayFullScreen(a.l,b.l) ; 
  get_DisplayNoteIndicator(a.l) ; 
  put_DisplayNoteIndicator(a.l) ; 
  get_DisplayCommentIndicator(a.l) ; 
  put_DisplayCommentIndicator(a.l) ; 
  get_DisplayExcel4Menus(a.l,b.l) ; 
  put_DisplayExcel4Menus(a.l,b.l) ; 
  get_DisplayRecentFiles(a.l) ; 
  put_DisplayRecentFiles(a.l) ; 
  get_DisplayScrollBars(a.l,b.l) ; 
  put_DisplayScrollBars(a.l,b.l) ; 
  get_DisplayStatusBar(a.l,b.l) ; 
  put_DisplayStatusBar(a.l,b.l) ; 
  DoubleClick(a.l) ; 
  get_EditDirectlyInCell(a.l,b.l) ; 
  put_EditDirectlyInCell(a.l,b.l) ; 
  get_EnableAutoComplete(a.l) ; 
  put_EnableAutoComplete(a.l) ; 
  get_EnableCancelKey(a.l,b.l) ; 
  put_EnableCancelKey(a.l,b.l) ; 
  get_EnableSound(a.l) ; 
  put_EnableSound(a.l) ; 
  get_EnableTipWizard(a.l,b.l) ; 
  put_EnableTipWizard(a.l,b.l) ; 
  get_FileConverters(a.l,b.l,c.l,d.l) ; 
  get_FileSearch(a.l) ; 
  get_FileFind(a.l) ; 
  _FindFile(a.l) ; 
  get_FixedDecimal(a.l,b.l) ; 
  put_FixedDecimal(a.l,b.l) ; 
  get_FixedDecimalPlaces(a.l,b.l) ; 
  put_FixedDecimalPlaces(a.l,b.l) ; 
  GetCustomListContents(a.l,b.l,c.l) ; 
  GetCustomListNum(a.l,b.l,c.l) ; 
  GetOpenFilename(a.l,b.l,c.l,d.l,e.l,f.l,g.l) ; 
  GetSaveAsFilename(a.l,b.l,c.l,d.l,e.l,f.l,g.l) ; 
  Goto(a.l,b.l,c.l) ; 
  get_Height(a.l,b.l) ; 
  put_Height(a.l,b.l) ; 
  Help(a.l,b.l,c.l) ; 
  get_IgnoreRemoteRequests(a.l,b.l) ; 
  put_IgnoreRemoteRequests(a.l,b.l) ; 
  InchesToPoints(a.l,b.l,c.l) ; 
  InputBox(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l) ; 
  get_Interactive(a.l,b.l) ; 
  put_Interactive(a.l,b.l) ; 
  get_International(a.l,b.l,c.l) ; 
  get_Iteration(a.l,b.l) ; 
  put_Iteration(a.l,b.l) ; 
  get_LargeButtons(a.l) ; 
  put_LargeButtons(a.l) ; 
  get_Left(a.l,b.l) ; 
  put_Left(a.l,b.l) ; 
  get_LibraryPath(a.l,b.l) ; 
  MacroOptions(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l) ; 
  MailLogoff(a.l) ; 
  MailLogon(a.l,b.l,c.l,d.l) ; 
  get_MailSession(a.l,b.l) ; 
  get_MailSystem(a.l,b.l) ; 
  get_MathCoprocessorAvailable(a.l,b.l) ; 
  get_MaxChange(a.l,b.l) ; 
  put_MaxChange(a.l,b.l) ; 
  get_MaxIterations(a.l,b.l) ; 
  put_MaxIterations(a.l,b.l) ; 
  get_MemoryFree(a.l,b.l) ; 
  get_MemoryTotal(a.l,b.l) ; 
  get_MemoryUsed(a.l,b.l) ; 
  get_MouseAvailable(a.l,b.l) ; 
  get_MoveAfterReturn(a.l,b.l) ; 
  put_MoveAfterReturn(a.l,b.l) ; 
  get_MoveAfterReturnDirection(a.l,b.l) ; 
  put_MoveAfterReturnDirection(a.l,b.l) ; 
  get_RecentFiles(a.l) ; 
  get_Name(a.l) ; 
  NextLetter(a.l,b.l) ; 
  get_NetworkTemplatesPath(a.l,b.l) ; 
  get_ODBCErrors(a.l) ; 
  get_ODBCTimeout(a.l) ; 
  put_ODBCTimeout(a.l) ; 
  get_OnCalculate(a.l,b.l) ; 
  put_OnCalculate(a.l,b.l) ; 
  get_OnData(a.l,b.l) ; 
  put_OnData(a.l,b.l) ; 
  get_OnDoubleClick(a.l,b.l) ; 
  put_OnDoubleClick(a.l,b.l) ; 
  get_OnEntry(a.l,b.l) ; 
  put_OnEntry(a.l,b.l) ; 
  OnKey(a.l,b.l,c.l) ; 
  OnRepeat(a.l,b.l,c.l) ; 
  get_OnSheetActivate(a.l,b.l) ; 
  put_OnSheetActivate(a.l,b.l) ; 
  get_OnSheetDeactivate(a.l,b.l) ; 
  put_OnSheetDeactivate(a.l,b.l) ; 
  OnTime(a.l,b.l,c.l,d.l,e.l) ; 
  OnUndo(a.l,b.l,c.l) ; 
  get_OnWindow(a.l,b.l) ; 
  put_OnWindow(a.l,b.l) ; 
  get_OperatingSystem(a.l,b.l) ; 
  get_OrganizationName(a.l,b.l) ; 
  get_Path(a.l,b.l) ; 
  get_PathSeparator(a.l,b.l) ; 
  get_PreviousSelections(a.l,b.l,c.l) ; 
  get_PivotTableSelection(a.l) ; 
  put_PivotTableSelection(a.l) ; 
  get_PromptForSummaryInfo(a.l,b.l) ; 
  put_PromptForSummaryInfo(a.l,b.l) ; 
  Quit() ; 
  RecordMacro(a.l,b.l,c.l) ; 
  get_RecordRelative(a.l,b.l) ; 
  get_ReferenceStyle(a.l,b.l) ; 
  put_ReferenceStyle(a.l,b.l) ; 
  get_RegisteredFunctions(a.l,b.l,c.l,d.l) ; 
  RegisterXLL(a.l,b.l,c.l) ; 
  Repeat(a.l) ; 
  ResetTipWizard(a.l) ; 
  get_RollZoom(a.l) ; 
  put_RollZoom(a.l) ; 
  Save(a.l,b.l) ; 
  SaveWorkspace(a.l,b.l) ; 
  get_ScreenUpdating(a.l,b.l) ; 
  put_ScreenUpdating(a.l,b.l) ; 
  SetDefaultChart(a.l,b.l) ; 
  get_SheetsInNewWorkbook(a.l,b.l) ; 
  put_SheetsInNewWorkbook(a.l,b.l) ; 
  get_ShowChartTipNames(a.l) ; 
  put_ShowChartTipNames(a.l) ; 
  get_ShowChartTipValues(a.l) ; 
  put_ShowChartTipValues(a.l) ; 
  get_StandardFont(a.l,b.l) ; 
  put_StandardFont(a.l,b.l) ; 
  get_StandardFontSize(a.l,b.l) ; 
  put_StandardFontSize(a.l,b.l) ; 
  get_StartupPath(a.l,b.l) ; 
  get_StatusBar(a.l,b.l) ; 
  put_StatusBar(a.l,b.l) ; 
  get_TemplatesPath(a.l,b.l) ; 
  get_ShowToolTips(a.l) ; 
  put_ShowToolTips(a.l) ; 
  get_Top(a.l,b.l) ; 
  put_Top(a.l,b.l) ; 
  get_DefaultSaveFormat(a.l) ; 
  put_DefaultSaveFormat(a.l) ; 
  get_TransitionMenuKey(a.l,b.l) ; 
  put_TransitionMenuKey(a.l,b.l) ; 
  get_TransitionMenuKeyAction(a.l,b.l) ; 
  put_TransitionMenuKeyAction(a.l,b.l) ; 
  get_TransitionNavigKeys(a.l,b.l) ; 
  put_TransitionNavigKeys(a.l,b.l) ; 
  Undo(a.l) ; 
  get_UsableHeight(a.l,b.l) ; 
  get_UsableWidth(a.l,b.l) ; 
  get_UserControl(a.l) ; 
  put_UserControl(a.l) ; 
  get_UserName(a.l,b.l) ; 
  put_UserName(a.l,b.l) ; 
  get_Value(a.l) ; 
  get_VBE(a.l) ; 
  get_Version(a.l,b.l) ; 
  get_Visible(a.l,b.l) ; 
  put_Visible(a.l,b.l) ; 
  Volatile(a.l,b.l) ; 
  _Wait(a.l,b.l) ; 
  get_Width(a.l,b.l) ; 
  put_Width(a.l,b.l) ; 
  get_WindowsForPens(a.l,b.l) ; 
  get_WindowState(a.l,b.l) ; 
  put_WindowState(a.l,b.l) ; 
  get_UILanguage(a.l,b.l) ; 
  put_UILanguage(a.l,b.l) ; 
  get_DefaultSheetDirection(a.l,b.l) ; 
  put_DefaultSheetDirection(a.l,b.l) ; 
  get_CursorMovement(a.l,b.l) ; 
  put_CursorMovement(a.l,b.l) ; 
  get_ControlCharacters(a.l,b.l) ; 
  put_ControlCharacters(a.l,b.l) ; 
  _WSFunction(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l,r.l,s.l,t.l,u.l,v.l,w.l,x.l,y.l,z.l,a.l,b.l,c.l,d.l,e.l,f.l) ; 
  get_EnableEvents(a.l) ; 
  put_EnableEvents(a.l) ; 
  get_DisplayInfoWindow(a.l) ; 
  put_DisplayInfoWindow(a.l) ; 
  Wait(a.l,b.l,c.l) ; 
  get_ExtendList(a.l) ; 
  put_ExtendList(a.l) ; 
  get_OLEDBErrors(a.l) ; 
  GetPhonetic(a.l,b.l) ; 
  get_COMAddIns(a.l) ; 
  get_DefaultWebOptions(a.l) ; 
  get_ProductCode(a.l) ; 
  get_UserLibraryPath(a.l) ; 
  get_AutoPercentEntry(a.l) ; 
  put_AutoPercentEntry(a.l) ; 
  get_LanguageSettings(a.l) ; 
  get_Dummy101(a.l) ; 
  Dummy12(a.l,b.l) ; 
  get_AnswerWizard(a.l) ; 
  CalculateFull() ; 
  FindFile(a.l,b.l) ; 
  get_CalculationVersion(a.l) ; 
  get_ShowWindowsInTaskbar(a.l) ; 
  put_ShowWindowsInTaskbar(a.l) ; 
  get_FeatureInstall(a.l) ; 
  put_FeatureInstall(a.l) ; 
  get_Ready(a.l) ; 
  Dummy13(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l,r.l,s.l,t.l,u.l,v.l,w.l,x.l,y.l,z.l,a.l,b.l,c.l,d.l,e.l) ; 
  get_FindFormat(a.l) ; 
  put_FindFormat(a.l) ; 
  get_ReplaceFormat(a.l) ; 
  put_ReplaceFormat(a.l) ; 
  get_UsedObjects(a.l) ; 
  get_CalculationState(a.l) ; 
  get_CalculationInterruptKey(a.l) ; 
  put_CalculationInterruptKey(a.l) ; 
  get_Watches(a.l) ; 
  get_DisplayFunctionToolTips(a.l) ; 
  put_DisplayFunctionToolTips(a.l) ; 
  get_AutomationSecurity(a.l) ; 
  put_AutomationSecurity(a.l) ; 
  get_FileDialog(a.l,b.l) ; 
  Dummy14() ; 
  CalculateFullRebuild() ; 
  get_DisplayPasteOptions(a.l) ; 
  put_DisplayPasteOptions(a.l) ; 
  get_DisplayInsertOptions(a.l) ; 
  put_DisplayInsertOptions(a.l) ; 
  get_GenerateGetPivotData(a.l) ; 
  put_GenerateGetPivotData(a.l) ; 
  get_AutoRecover(a.l) ; 
  get_Hwnd(a.l) ; 
  get_Hinstance(a.l) ; 
  CheckAbort(a.l) ; 
  get_ErrorCheckingOptions(a.l) ; 
  get_AutoFormatAsYouTypeReplaceHyperlinks(a.l) ; 
  put_AutoFormatAsYouTypeReplaceHyperlinks(a.l) ; 
  get_SmartTagRecognizers(a.l) ; 
  get_NewWorkbook(a.l) ; 
  get_SpellingOptions(a.l) ; 
  get_Speech(a.l) ; 
  get_MapPaperSize(a.l) ; 
  put_MapPaperSize(a.l) ; 
  get_ShowStartupDialog(a.l) ; 
  put_ShowStartupDialog(a.l) ; 
  get_DecimalSeparator(a.l) ; 
  put_DecimalSeparator(a.l) ; 
  get_ThousandsSeparator(a.l) ; 
  put_ThousandsSeparator(a.l) ; 
  get_UseSystemSeparators(a.l) ; 
  put_UseSystemSeparators(a.l) ; 
  get_ThisCell(a.l) ; 
  get_RTD(a.l) ; 
  get_DisplayDocumentActionTaskPane(a.l) ; 
  put_DisplayDocumentActionTaskPane(a.l) ; 
  DisplayXMLSourcePane(a.l) ; 
  get_ArbitraryXMLSupportAvailable(a.l) ; 
  Support(a.l,b.l,c.l,d.l) ; 
EndInterface

Interface Workbooks Extends IDispatch
  get_Application(a.l) ; 
  get_Creator(a.l) ; 
  get_Parent(a.l) ; 
  Add(a.l,a.l,a.l,a.l,b.l,c.l) ; I changed this one to pass a VARIANT
  Close(a.l) ; 
  get_Count(a.l) ; 
  get_Item(a.l,b.l) ; 
  get__NewEnum(a.l) ; 
  _Open(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l) ; 
  __OpenText(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l) ; 
  get__Default(a.l,b.l) ; 
  _OpenText(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l) ; 
  Open(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l) ; 
  OpenText(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l,r.l,s.l) ; 
  OpenDatabase(a.l,b.l,c.l,d.l,e.l,f.l) ; 
  CheckOut(a.l) ; 
  CanCheckOut(a.l,b.l) ; 
  _OpenXML(a.l,b.l,c.l) ; 
  OpenXML(a.l,b.l,c.l,d.l) ; 
EndInterface

Interface _Workbook Extends IDispatch
  get_Application(a.l) ; 
  get_Creator(a.l) ; 
  get_Parent(a.l) ; 
  get_AcceptLabelsInFormulas(a.l) ; 
  put_AcceptLabelsInFormulas(a.l) ; 
  Activate(a.l) ; 
  get_ActiveChart(a.l) ; 
  get_ActiveSheet(a.l) ; 
  get_Author(a.l,b.l) ; 
  put_Author(a.l,b.l) ; 
  get_AutoUpdateFrequency(a.l) ; 
  put_AutoUpdateFrequency(a.l) ; 
  get_AutoUpdateSaveChanges(a.l) ; 
  put_AutoUpdateSaveChanges(a.l) ; 
  get_ChangeHistoryDuration(a.l) ; 
  put_ChangeHistoryDuration(a.l) ; 
  get_BuiltinDocumentProperties(a.l) ; 
  ChangeFileAccess(a.l,b.l,c.l,d.l) ; 
  ChangeLink(a.l,b.l,c.l,d.l) ; 
  get_Charts(a.l) ; 
  Close(a.l,b.l,c.l,d.l) ; 
  get_CodeName(a.l) ; 
  get__CodeName(a.l) ; 
  put__CodeName(a.l) ; 
  get_Colors(a.l,b.l,c.l) ; 
  put_Colors(a.l,b.l,c.l) ; 
  get_CommandBars(a.l) ; 
  get_Comments(a.l,b.l) ; 
  put_Comments(a.l,b.l) ; 
  get_ConflictResolution(a.l) ; 
  put_ConflictResolution(a.l) ; 
  get_Container(a.l) ; 
  get_CreateBackup(a.l,b.l) ; 
  get_CustomDocumentProperties(a.l) ; 
  get_Date1904(a.l,b.l) ; 
  put_Date1904(a.l,b.l) ; 
  DeleteNumberFormat(a.l,b.l) ; 
  get_DialogSheets(a.l) ; 
  get_DisplayDrawingObjects(a.l,b.l) ; 
  put_DisplayDrawingObjects(a.l,b.l) ; 
  ExclusiveAccess(a.l,b.l) ; 
  get_FileFormat(a.l,b.l) ; 
  ForwardMailer(a.l) ; 
  get_FullName(a.l,b.l) ; 
  get_HasMailer(a.l,b.l) ; 
  put_HasMailer(a.l,b.l) ; 
  get_HasPassword(a.l,b.l) ; 
  get_HasRoutingSlip(a.l,b.l) ; 
  put_HasRoutingSlip(a.l,b.l) ; 
  get_IsAddin(a.l) ; 
  put_IsAddin(a.l) ; 
  get_Keywords(a.l,b.l) ; 
  put_Keywords(a.l,b.l) ; 
  LinkInfo(a.l,b.l,c.l,d.l,e.l,f.l) ; 
  LinkSources(a.l,b.l,c.l) ; 
  get_Mailer(a.l) ; 
  MergeWorkbook(a.l) ; 
  get_Modules(a.l) ; 
  get_MultiUserEditing(a.l,b.l) ; 
  get_Name(a.l) ; 
  get_Names(a.l) ; 
  NewWindow(a.l,b.l) ; 
  get_OnSave(a.l,b.l) ; 
  put_OnSave(a.l,b.l) ; 
  get_OnSheetActivate(a.l,b.l) ; 
  put_OnSheetActivate(a.l,b.l) ; 
  get_OnSheetDeactivate(a.l,b.l) ; 
  put_OnSheetDeactivate(a.l,b.l) ; 
  OpenLinks(a.l,b.l,c.l,d.l) ; 
  get_Path(a.l,b.l) ; 
  get_PersonalViewListSettings(a.l) ; 
  put_PersonalViewListSettings(a.l) ; 
  get_PersonalViewPrintSettings(a.l) ; 
  put_PersonalViewPrintSettings(a.l) ; 
  PivotCaches(a.l) ; 
  Post(a.l,b.l) ; 
  get_PrecisionAsDisplayed(a.l,b.l) ; 
  put_PrecisionAsDisplayed(a.l,b.l) ; 
  _PrintOut(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l) ; 
  PrintPreview(a.l,b.l) ; 
  _Protect(a.l,b.l,c.l) ; 
  ProtectSharing(a.l,b.l,c.l,d.l,e.l,f.l) ; 
  get_ProtectStructure(a.l) ; 
  get_ProtectWindows(a.l) ; 
  get_ReadOnly(a.l,b.l) ; 
  get__ReadOnlyRecommended(a.l,b.l) ; 
  RefreshAll() ; 
  Reply(a.l) ; 
  ReplyAll(a.l) ; 
  RemoveUser(a.l) ; 
  get_RevisionNumber(a.l,b.l) ; 
  Route(a.l) ; 
  get_Routed(a.l,b.l) ; 
  get_RoutingSlip(a.l) ; 
  RunAutoMacros(a.l,b.l) ; 
  Save(a.l) ; 
  _SaveAs(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l) ; 
  SaveCopyAs(a.l,b.l) ; 
  get_Saved(a.l,b.l) ; 
  put_Saved(a.l,b.l) ; 
  get_SaveLinkValues(a.l,b.l) ; 
  put_SaveLinkValues(a.l,b.l) ; 
  SendMail(a.l,b.l,c.l,d.l) ; 
  SendMailer(a.l,b.l,c.l) ; 
  SetLinkOnData(a.l,b.l,c.l) ; 
  get_Sheets(a.l) ; 
  get_ShowConflictHistory(a.l,b.l) ; 
  put_ShowConflictHistory(a.l,b.l) ; 
  get_Styles(a.l) ; 
  get_Subject(a.l,b.l) ; 
  put_Subject(a.l,b.l) ; 
  get_Title(a.l,b.l) ; 
  put_Title(a.l,b.l) ; 
  Unprotect(a.l,b.l) ; 
  UnprotectSharing(a.l) ; 
  UpdateFromFile(a.l) ; 
  UpdateLink(a.l,b.l,c.l) ; 
  get_UpdateRemoteReferences(a.l,b.l) ; 
  put_UpdateRemoteReferences(a.l,b.l) ; 
  get_UserControl(a.l) ; 
  put_UserControl(a.l) ; 
  get_UserStatus(a.l,b.l) ; 
  get_CustomViews(a.l) ; 
  get_Windows(a.l) ; 
  get_Worksheets(a.l) ; 
  get_WriteReserved(a.l,b.l) ; 
  get_WriteReservedBy(a.l,b.l) ; 
  get_Excel4IntlMacroSheets(a.l) ; 
  get_Excel4MacroSheets(a.l) ; 
  get_TemplateRemoveExtData(a.l) ; 
  put_TemplateRemoveExtData(a.l) ; 
  HighlightChangesOptions(a.l,b.l,c.l) ; 
  get_HighlightChangesOnScreen(a.l) ; 
  put_HighlightChangesOnScreen(a.l) ; 
  get_KeepChangeHistory(a.l) ; 
  put_KeepChangeHistory(a.l) ; 
  get_ListChangesOnNewSheet(a.l) ; 
  put_ListChangesOnNewSheet(a.l) ; 
  PurgeChangeHistoryNow(a.l,b.l) ; 
  AcceptAllChanges(a.l,b.l,c.l) ; 
  RejectAllChanges(a.l,b.l,c.l) ; 
  PivotTableWizard(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l,n.l,o.l,p.l,q.l) ; 
  ResetColors() ; 
  get_VBProject(a.l) ; 
  FollowHyperlink(a.l,b.l,c.l,d.l,e.l,f.l,g.l) ; 
  AddToFavorites() ; 
  get_IsInplace(a.l) ; 
  PrintOut(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l) ; 
  WebPagePreview() ; 
  get_PublishObjects(a.l) ; 
  get_WebOptions(a.l) ; 
  ReloadAs(a.l) ; 
  get_HTMLProject(a.l) ; 
  get_EnvelopeVisible(a.l) ; 
  put_EnvelopeVisible(a.l) ; 
  get_CalculationVersion(a.l) ; 
  Dummy17(a.l) ; 
  sblt(a.l) ; 
  get_VBASigned(a.l) ; 
  get_ShowPivotTableFieldList(a.l) ; 
  put_ShowPivotTableFieldList(a.l) ; 
  get_UpdateLinks(a.l) ; 
  put_UpdateLinks(a.l) ; 
  BreakLink(a.l,b.l) ; 
  Dummy16() ; 
  SaveAs(a.l,b.l,c.l,d.l,e.l,f.l,g.l,h.l,i.l,j.l,k.l,l.l,m.l) ; 
  get_EnableAutoRecover(a.l) ; 
  put_EnableAutoRecover(a.l) ; 
  get_RemovePersonalInformation(a.l) ; 
  put_RemovePersonalInformation(a.l) ; 
  get_FullNameURLEncoded(a.l,b.l) ; 
  CheckIn(a.l,b.l,c.l) ; 
  CanCheckIn(a.l) ; 
  SendForReview(a.l,b.l,c.l,d.l) ; 
  ReplyWithChanges(a.l) ; 
  EndReview() ; 
  get_Password(a.l) ; 
  put_Password(a.l) ; 
  get_WritePassword(a.l) ; 
  put_WritePassword(a.l) ; 
  get_PasswordEncryptionProvider(a.l) ; 
  get_PasswordEncryptionAlgorithm(a.l) ; 
  get_PasswordEncryptionKeyLength(a.l) ; 
  SetPasswordEncryptionOptions(a.l,b.l,c.l,d.l) ; 
  get_PasswordEncryptionFileProperties(a.l) ; 
  get_ReadOnlyRecommended(a.l) ; 
  put_ReadOnlyRecommended(a.l) ; 
  Protect(a.l,b.l,c.l) ; 
  get_SmartTagOptions(a.l) ; 
  RecheckSmartTags() ; 
  get_Permission(a.l) ; 
  get_SharedWorkspace(a.l) ; 
  get_Sync(a.l) ; 
  SendFaxOverInternet(a.l,b.l,c.l) ; 
  get_XmlNamespaces(a.l) ; 
  get_XmlMaps(a.l) ; 
  XmlImport(a.l,b.l,c.l,d.l,e.l) ; 
  get_SmartDocument(a.l) ; 
  get_DocumentLibraryVersions(a.l) ; 
  get_InactiveListBorderVisible(a.l) ; 
  put_InactiveListBorderVisible(a.l) ; 
  get_DisplayInkComments(a.l) ; 
  put_DisplayInkComments(a.l) ; 
  XmlImportXml(a.l,b.l,c.l,d.l,e.l) ; 
  SaveAsXMLData(a.l,b.l) ; 
  ToggleFormsDesign() ; 
EndInterface

Global oExcel._Application
Global oWorkbooks.Workbooks
Global oWorkbook._Workbook

Global None.VARIANT
None\vt    = #VT_ERROR 
None\scode = #DISP_E_PARAMNOTFOUND 
Debug SizeOf(None)

Structure MyDummy
  array.l[4]
EndStructure

*pDummy.MyDummy = None
Debug *pDummy\array[0]

Procedure.s Uni2Ansi(unicodestr.l)
  lenA = WideCharToMultiByte_(#CP_ACP, 0, unicodestr, -1, 0, 0, 0, 0);
  ansistr.s = Space(lenA)
  If (lenA > 0)
    WideCharToMultiByte_(#CP_ACP, 0, unicodestr, -1, @ansistr, lenA, 0, 0);
  EndIf
  ProcedureReturn ansistr
EndProcedure

Procedure.l Ansi2Uni(ansistr.s)
  lenA.l = Len(ansistr)
  lenW = MultiByteToWideChar_(#CP_ACP, 0, ansistr, lenA, 0, 0)
  If (lenW > 0) ; Check whether conversion was successful
    unicodestr = SysAllocStringLen_(0, lenW)
    MultiByteToWideChar_(#CP_ACP, 0, ansistr, lenA, unicodestr, lenW)
    result = unicodestr
    SysFreeString_(unicodestr)
    ProcedureReturn result
  Else 
    ProcedureReturn 0
  EndIf
EndProcedure

;- Start program
OnErrorGoto(?Error)

OleInitialize_(0) 

If CoCreateInstance_(?CLSID_xlApplication,0,#CLSCTX_LOCAL_SERVER,?IID_xlApplication,@oExcel)<>0
  MessageRequester("Warning:","Couldn't init oExcel",0)
  End
EndIf
Debug oExcel

oExcel\put_Caption(Ansi2Uni("Excel from PureBasic"))
;VariantChangeType_( @Variant.VARIANT, *oVarDesc\union,0,#VT_INT)

oExcel\put_Visible(lcid,#True)
oExcel\get_Workbooks(@oWorkbooks)
Debug oWorkbooks

If oWorkbooks\Add(*pDummy\array[0],*pDummy\array[1],*pDummy\array[2], *pDummy\array[3], lcid, @oWorkbook) = #S_OK
  Debug oWorkbook
  Delay(5000)  ; Wait for 5 seconds
Else
  SetErrorNumber(err)
EndIf


;- End program
Finish:
oExcel\Quit()
If oWorkbook
  oWorkbook\Release()
EndIf
If oWorkbooks
  oWorkbooks\Release()
EndIf
oExcel\Release()

OleUninitialize_()

End

;- Error handler
Error:
error.s = Space(500)
error   = GetErrorDescription()
CRLF.s  = Chr(13)+Chr(10)
msg.s = ""
msg = Str(GetErrorLineNR()) + ":" + error + " (" + Hex(GetErrorNumber()) + " )" + CRLF
msg = msg + "Severitycode " + Bin((err >> 30) & $0003) + " " + CRLF
msg = msg + "Facilitycode " + Str((err >> 16) & $0FFF) + " " + CRLF
msg = msg + "Errorcode " + Str(err & $FFFF)
MessageRequester("Error", msg, 0)
Goto Finish

End

DataSection
  CLSID_xlApplication:      ;{00024500-0000-0000-C000-000000000046}
  Data.l $00024500
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection

DataSection
  IID_xlApplication:        ;{000208D5-0000-0000-C000-000000000046}
  Data.l $000208D5
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
Post Reply