C++/VB - Scripting an Excel add-in
Asked By Robert Schwenn
17-Feb-08 06:35 PM
Hi,
I have a vbscript that gets and controls Excel via Excel's built-in objects.
But now I want to use objects and functions from a plugin that's currently loaded in Excel. I tried the following:
Set xl = CreateObject("Excel.Application")
set wbAddin = xl.Workbooks("AddinName.xla") 'successfull!
set ObjectFromWithinAddin = wbAddin.PublicObject 'Error!
dummy = wbAddin.PublicFunction() 'Error!
==> How can this be done?
Thanks.
Robert
Excel
(1)
VBA
(1)
ObjectFromWithinAddin
(1)
WbAddin.PublicObject
(1)
CreateObject
(1)
WbAddin
(1)
Vbscript
(1)
Plugin
(1)
Tim Williams replied...
Have you tried doing this from within Excel (using VBA) ?
If it does not work there then it most likely will not work in VBscript.
Tim
Robert Schwenn replied...
Now i tried it ;-).
It doesn't work that way. And I realized that the problem is mostly related to
Excel. In a VBA project, You only have to set a link to the other VBA project.
But in the excel.programming newsgroup I found that - without a link to the
add-in - a function can be called this way:
dummy = xl.Run("AddinName.xla!PublicFunction", Arg1, Arg2 ...)
I will ask there how to access objects...
Robert

system32 \ tskill.exe And EXCEL by VBS file. . . C++ / VB Hi. I got a job about writing some txt files into a Excel sheet. Some text1: value1 Some text2: value2 . . . and so on. . . So today I wrote a A problem I found was that if one said something wrong to the msgBoxes from Excel, or whatever, then it could freeze the sheet. . . To avoid that, I simply used the Say No to the first question, and the freeze problem is gone :) My knowlede about Excel syntax is almost one line, something like this: oExcelSheet.cells(1, 1).value so any oTargetFile, oFi, sR, iU _ , arr(), arr2, s0, s1, iRowBeg, iRowEnd, sVer, bNewSheet set fso = createObject("scripting.fileSystemObject") set wso = createObject("wScript.shell") sub BeginCScript(bDebug, bMaxWin) if "WSCRIPT" = uCase(fso.getBaseName(wScript.fullName)) then if if not fso.folderExists(sTargetPath) _ then fso.createFolder(sTargetPath) ' sExcelEXE = "%ProgramFiles% \ Microsoft Office \ Office10 \ Excel.exe" sExcelEXE = fso.getAbsolutePathName(wso._ expandEnvironmentStrings(sExcelEXE)) if not fso.fileExists(sExcelEXE) then sExcelEXE = "excel.exe" ' sVer = fso.getFileVersion(sExcelEXE) if sVer = "" then sVer = "?" ' wScript.echo """excel.exe"", ver " & sVer
in VB6) problem C++ / VB Hi folks, I tried to create a dll library for Excel VBA but I got an error message which is out of my knowlege. Please help. In clName End Sub clName: Public Function SN(strSheet As Integer) As String Dim XLApp As Excel.Application SN = XLApp.ActiveWorkbook.Sheets(strSheet).Name End Function Then, I compiled it to dll and registed it. After all, I added the library to Excel vba and had the following code to call it. Public Sub test2() Dim xlFunction As test AddFromFile (1) XLApp.ActiveWorkbook.Sheets (1) MyExternalObj.ChangeCell (1) XLApp.CurSheet (1) MyLib.MyClass (1) Excel (1) XlFunction.pShtName.sCell (1) VBA (1) ? Hi folks, ? ? I tried to create a dll library for Excel VBA but I got an error message ? which is out of my knowlege. Please help
OnTime Not Working C++ / VB I have created the following VBS code: MyTest Set objExcel = CreateObject("Excel.Application") MsgBox "Before OnTime" objExcel.Application.OnTime Now + TimeValue("00:00:05"), "MyTest" MsgBox "After happening since I am not getting any errors. Any help would be appreciated. VBScript Discussions Excel (1) Application.OnTime (1) VBA (1) ObjExcel.Application.OnTime (1) VBScript (1) CreateObject (1) TimeValue (1) GetRef (1) I cannot run it because I do not have Excel, but what exactly are you trying to do? Do you want "mytest()" to run once illustrates them. The first is due to the fact that you exit your program before Excel has a chance to do anything. When you exit the VBScript program, the Excel directive goes away, too. So sorry. You have to specifically insist that Excel not go
Thank you miztaken Win32 OLE Discussions Visual Studio (1) PowerPoint (1) GetTypedObjectForIUnknown (1) Office (1) Excel (1) VB (1) PtrToPersistStorage (1) StgCreateDocfile (1) Solutions should be determined after requirements are specified DOC itself. r u getting me? thank you For any inserted Office document, examples include Excel Spreadsheet, Power Point Presentation, Visio, etc., extraction is easy. These documents can all be extracted load and save these documents. Use CoCreateInstance to instantiate the OLE Auomation Application(i.e., Excel, Power Point, Visio, etc). I gave the recipe in one of my previous posting in your thread. The only problem with excel files is that once extracted they are invisible. You must make them visible to see group / microsoft.public.dotnet.framework.interop / browse_thread / thread / 2ce134250d3d061b / 64d73629838242f4?hl = en&lnk = st&q = excel+michael+phillips#64d73629838242f4 I have not tried inserted images. However using the DFViewer, I see me say by computing binaries only? Also i viewed the code you provided to extract excel, i suppose it do not require creating an instance of EXCEL. Is this true? By reading the compobj i figured out if the excel Workbook stream is BIFF8, is this the right way to probe BIFF format? Also i
HKEY_CLASSES_ROOT \ txtfile \ shell \ backupfile \ command] @ = "cscript / / b H: \ Software \ shell \ xbcp.vbs "%1" "txt"" For excel file REGEDIT4 [HKEY_CLASSES_ROOT \ xlsfile \ shell \ backupfile] @ = "Backup Excel File" [HKEY_CLASSES_ROOT \ xlsfile \ shell \ backupfile \ command] @ = "cscript / / b H: \ Software \ shell \ xbcp.vbs "%1" "xls fnext fnprefix = mid(fn, 1, instrrev(fn, fnext) - 2) wscript.echo "fnprefix = " & fnprefix Set fso = CreateObject("Scripting.FileSystemObject") if fso.FileExists(fn) then wDate = Year(Now) & Right("00" & Month(Now), 2) & Right("00" & Day(Now), 2) newfn = fnprefix & "_" & wdate & "." & fnext set fso1 = CreateObject("Scripting.FileSystemObject") fncnt = 0 if fso1.FileExists(newfn) then while (fso1.FileExists(newfn)) fncnt = fncnt fso.copyfile fn, newfn end if wscript.echo ("DONE") '~~ WScript.Sleep 1000 VBScript Discussions Microsoft Excel (1) Microsoft Word (1) Office (1) Excel (1) CreateObject (1) EditFlags (1) ObjArgs (1) Month (1) I do not use MS Office, so I I do not actually _know_ why, but I suspect that ms is not handling the excel (xls) extension the same as the text (txt) extension. I suspect that ms has devised