Author Topic: COM OLE  (Read 3673 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
Re: COM OLE
« Reply #45 on: March 23, 2021, 12:23:19 PM »
print "CLSID: " + guidtxt ObjectGuid

oExcelApp = COM::CREATE(:SET, "{00024500-0000-0000-C000-000000000046}")

It worked under SB.
« Last Edit: March 23, 2021, 12:34:12 PM by John »

JRS

  • Guest
Re: COM OLE
« Reply #46 on: March 23, 2021, 12:51:19 PM »
Charles,

Attached is the following. I assume you still have the SCRIBA.INI and ScriptBasic installed on your box.

sbc.exe - console w/styles
sbw.exe - true Windows consoleless interpreter w/styles
com.dll - Dave's / Mike's COM extension module
com.dll.debug - COM extension with debug messages
com.sbi - COM include/import

Charles Pegge

  • Guest
Re: COM OLE
« Reply #47 on: March 23, 2021, 01:39:14 PM »
Thanks.

Is this still null?
print @oExcelApp


JRS

  • Guest
Re: COM OLE
« Reply #48 on: March 23, 2021, 01:45:34 PM »
Yep.

Prints zero.

Also the last thing to print. The others never print (pop messageboxes)

Charles Pegge

  • Guest
Re: COM OLE
« Reply #49 on: March 23, 2021, 03:11:49 PM »
In ComUtil.inc:

Code: [Select]
  'CLSCTX_INPROC_SERVER            = 0x1
  'CLSCTX_INPROC_HANDLER           = 0x2
  'CLSCTX_LOCAL_SERVER             = 0x4
  'CLSCTX_INPROC_SERVER16          = 0x8
  'CLSCTX_REMOTE_SERVER            = 0x10
  '
  int context = 15 '1 2 4 8


could you try with the context set to 5, then 4

This value is used by CocreateInstance.

JRS

  • Guest
Re: COM OLE
« Reply #50 on: March 23, 2021, 03:12:50 PM »
Charles,

You can try Office free for a month which gives Excel to play with. $99 / year if you decide to subscribe. Get the 32 bit version of office.

https://www.microsoft.com/en-us/microsoft-365/try
« Last Edit: March 23, 2021, 03:42:57 PM by John »

JRS

  • Guest
Re: COM OLE
« Reply #51 on: March 23, 2021, 03:29:14 PM »
I think you're making progress.

oWorkbook is the last dialog to show. I'm now seeing the same Excel loading pause in O2 as I do in SB. I get the same dialogs for 4 and 5.

Code: [Select]
'07:01 23/03/2021
$filename "exceldemo.exe"
'uses RTL32                                   
uses  COM/COMutil                                   
 
CoInitialize null
 
string filename
int i, j
 
filename = "C:\OxygenBasic\examples\COM\exceldemo.xls"
CreateInterfaceByName "Excel.Application" oExcelApp
print "CLSID: " + guidtxt ObjectGuid
print "ERROR: " + hex(err)
print "oExcelApp: " + @oExcelApp
ObjectByName(oExcelApp, "Workbooks", BSTR {}, oWorkBook)
print "oWorkBook: " + @oWorkBook
ObjectByName(oWorkBook, "Add", BSTR {0}, oExcelWorkbook)
print "oExcelWorkbook: " + @oExcelWorkbook
ObjectByName(oExcelWorkbook, "Worksheets", BSTR {1}, oExcelSheet)
print "oExcelSheet: " + @oExcelSheet
ObjectByName(oExcelSheet, "Range", BSTR {"G3"}, oRange)
print "oRange: " + @oRange
LetByName(oRange, "Value", 123)
oRange.Release
ObjectByName(oExcelSheet, "Range", BSTR {"B1:B5"}, oRange)
CallByName(oRange, "BorderAround", BSTR {1, -4138, 3})
ObjectByName(oRange, "Interior", BSTR {1}, oInterior)
LetByName(oInterior, "ColorIndex", 38)
LetByName(oInterior, "Pattern", "xlSolid")
oRange.Release
oInterior.Release
for i = 0 to 10
  for j = 0 to 10
    ObjectByName(oExcelSheet, "Cells", BSTR {i, j}, oCell)
    LetByName(oCell, "Value", "test-" + str(i) + "-" + str(j))
    oCell.Release
  next j   
next i   
CallByName(oExcelWorkbook, "SaveAs", BSTR {filename})
CmdByName(oExcelWorkbook, "Close")
CmdByName(oExcelApp, "Quit")
oExcelSheet.Release
oExcelWorkbook.Release
oWorkBook.Release
oExcelApp.Release

CoUninitialize
 
print "Speadsheet Created."

Charles Pegge

  • Guest
Re: COM OLE
« Reply #52 on: March 23, 2021, 03:37:35 PM »
Did it create an interface with context=5 ?

JRS

  • Guest
Re: COM OLE
« Reply #53 on: March 23, 2021, 03:44:27 PM »
Yes.

First 4 which I made the dialog screen shots of then 5 which showed the same dialog sequence.

Charles Pegge

  • Guest
Re: COM OLE
« Reply #54 on: March 23, 2021, 04:04:28 PM »
Good! I will keep context=5.

Did you get Sage to work with your SB COM instead of BOI ?

Yes I see you did on page 1
« Last Edit: March 23, 2021, 04:13:51 PM by Charles Pegge »

JRS

  • Guest
Re: COM OLE
« Reply #55 on: March 23, 2021, 04:13:27 PM »
It was only a name change for the Open Sage forum.

The examples I posted in this thread are using the COM syntax of what I have been using all along.


Charles Pegge

  • Guest
Re: COM OLE
« Reply #56 on: March 23, 2021, 04:18:45 PM »
So getting an excel workbook interface is a problem in both SB and o2 ?

JRS

  • Guest
Re: COM OLE
« Reply #57 on: March 23, 2021, 04:19:22 PM »
Here is where the Sage 100 ERP is at. (context = 5)

BOI = Business Object Interface

Code: OxygenBasic
  1. ' O2 Sage BOI
  2.  
  3. $filename "t.exe"                                    
  4. uses  COM/COMutil                                    
  5.  
  6.  
  7. CoInitialize null
  8.  
  9. CreateInterfaceByName "ProvideX.Script" oscript
  10. CallByName(oscript, "Init", BSTR {"C:\Sage\Sage 100 Standard\MAS90\Home"})
  11.  
  12. ObjectByName(oscript, "NewObject", BSTR {"SY_Session"},osession)
  13. CallByName(osession, "nSetUser", BSTR {"js", "northstar"})
  14. CallByName(osession, "nsetcompany", BSTR {"ABC"})
  15. CallByName(osession, "nSetDate", BSTR {"A/R", "20210322"})
  16. CallByName(osession, "nSetModule", BSTR {"A/R"})
  17. ObjectByName(oscript, "NewObject", BSTR {"AR_Customer_svc"}, osession, ocust)
  18. CmdByName(ocust, "nMoveFirst")
  19. GetByName(ocust, "sCustomerNo", customerno)
  20. GetByName(ocust, "sCustomerName", customername)
  21. GetByName(ocust, "sCity", city)
  22. GetByName(ocust, "sState", state)
  23. GetByName(ocust, "sTelephoneNo", telephoneno)
  24. CmdByName(ocust, "DropObject")
  25. CmdByName(osession, "DropObject")
  26.  
  27. ' print @osession 'check pointer
  28.  
  29. print "Customer:  ", customerno, "  ", customername, "  ", city, "  ", state, "  ", telephoneno
  30.  
  31. oscript.Release                                      
  32. CoUninitialize
  33.  

JRS

  • Guest
Re: COM OLE
« Reply #58 on: March 23, 2021, 04:20:24 PM »
So getting an excel workbook interface is a problem in both SB and o2 ?

My SB example posted works flawlessly.

Charles Pegge

  • Guest
Re: COM OLE
« Reply #59 on: March 23, 2021, 04:58:51 PM »
For Sage. Line 17 osession we have to do it directly with variants

must go to bed!