Author Topic: Couple Api ideas for embedding  (Read 92352 times)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Couple Api ideas for embedding
« Reply #60 on: June 18, 2014, 06:06:20 PM »
I have been chipping away at getting theming working in XP first and then Win7 afterward. I found this VB6 Manifest Creator code and was able to at least compile it and the form was themed. That lets me know that it's possible and even by me.  8)



dzzie

  • Guest
Re: Couple Api ideas for embedding
« Reply #61 on: June 18, 2014, 06:29:05 PM »
nice :)

dzzie

  • Guest
Re: Couple Api ideas for embedding
« Reply #62 on: June 19, 2014, 03:41:42 PM »
I was able to get an excel sample working. Had to make a small change to COM.dll to support creating activex exe com objects.

Patch:
https://github.com/dzzie/ScriptBasic_Control/commit/fdfe485bbadc3f676435635fc571687a2b3227a3

full file:
https://raw.githubusercontent.com/dzzie/ScriptBasic_Control/master/engine/COM_Extension_DLL/COM.cpp

Code: [Select]
import com.inc

'on error resume next

filename = "c:\\warehouse.xls"

if FileExists(filename) then
print "File already exists deleting: ", filename,"\n"
delete filename
end if

oExcelApp = CreateObject("Excel.Application")

if oExcelApp = 0 then
    print "Failed to create Excel Object do you have it installed?"
    return
end if

'vbs: Set ExcelWorkbook = ExcelApp.Workbooks.Add
oWorkBook = CallByName(oExcelApp, "Workbooks", vbGet)
oExcelWorkbook = CallByName(oWorkBook, "Add")

'vbs: Set ExcelSheet = ExcelWorkbook.Worksheets(1)
oExcelSheet = CallByName(oExcelWorkbook, "Worksheets", vbGet, 1)

print "Adding cells...\n"

for i=0 to 10
   for j=0 to 10
'vbs: ExcelSheet.Cells(i, j).Value = "test-" & i & "-" & j
oCell = CallByName(oExcelSheet, "Cells", vbGet, i, j)
CallByName(oCell, "Value", vbLet, "test-" & i & "-" & j)
ReleaseObject(oCell)
next
next

print "Saving document as:", filename, "\n"

CallByName(oExcelWorkbook, "SaveAs", vbMethod, filename)
CallByName(oExcelWorkbook, "Close")
CallByName(oExcelApp, "Quit")

print "Releasing objects from memory...\n"

ReleaseObject(oExcelSheet)
ReleaseObject(oExcelWorkbook)
ReleaseObject(oWorkBook)
ReleaseObject(oExcelApp)

print "Script complete!\n"
« Last Edit: June 19, 2014, 03:58:53 PM by dzzie »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Couple Api ideas for embedding
« Reply #63 on: June 19, 2014, 05:52:42 PM »
That is very cool Dave. It looks like you're calling another object (Workbooks) with CallByName(), is that correct?

Can you post a compiled COM.dll as I'm still getting my Visual Studio 8 setup for this project?

This Script BASIC VB Classic project keeps getting more interesting by the minute.  8)
« Last Edit: June 19, 2014, 05:56:58 PM by support »

dzzie

  • Guest
Re: Couple Api ideas for embedding
« Reply #64 on: June 19, 2014, 06:38:10 PM »
attached is the updated dll for scriba v2.2.

I also added a new export TypeName(obj) which will return the class name of the COM object.
I am pretty much done with another command which will allow you to list the public methods/properties of a given com object
The SBCallBackEx export, usable by VB5/6 UIs now also allows the VB form to call back into script basic function using arbitrary number
of arguments of string or long type, and can handle string or long return values from script basic back to vb

In the excel example, any of the variables startign with o are COM object pointers, there are a bunch of them.

without the dot notation, you have to handle access one step at a time.

so in vbscript the single line:

Set ExcelWorkbook = ExcelApp.Workbooks.Add

Has to be converted out to:

oWorkBook = CallByName(oExcelApp, "Workbooks", vbGet)
oExcelWorkbook = CallByName(oWorkBook, "Add")

To simplify this, I could probably make callbyname parse complex strings and automate these
steps which could potentially reduce it down to a very managable:

oExcelWorkbook = CallByName(oExcelApp, "ExcelApp.Workbooks.Add")

or in more complicated form:

ExcelSheet.Cells(i, j).Value = x




Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Couple Api ideas for embedding
« Reply #65 on: June 19, 2014, 07:04:33 PM »
Thanks Dave!

I'm installing Office 2010 Pro in my XP VirtualBox so I can try your new COM features with the SB ext. module.

Being able to browse COM objects will be nice. Something to add to the SB debugger your working on possibly.

« Last Edit: June 19, 2014, 10:29:29 PM by support »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Couple Api ideas for embedding
« Reply #66 on: June 19, 2014, 09:54:06 PM »
Works fine with Office 2010 Pro on XP.