Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automating Macros for CSV files
Been all over the 'net looking for an answer to this one, here goes....
I need to collect data in a C++ Net application, then from that same application automatically (with no keys pressed) do the following: 1) Save the file as an Excel-compatible dataset (I chose CSV for its simplicity) 2) Fire up Excel and load up the dataset into a worksheet 3) Execute a very extensive macro (over 800 lines) in Excel - this macro can be installed as a global macro e.g. XLstart directory (see note below) as a separate file or worksheet (optional) 4) Leave the focus on the Excel window so the results will appear foremost to the user Seems simple, and I've had success with steps 1 and 2 using the Microsoft::Office::Interop method. HOWEVER, when Excel is started from my C++ application, none of the global macros are available. This seems to be some kind of security limitation of global macros. Yes, I tried all four security settings to no avail. (If you fire up Excel by itself, global macros in XLStart are available -- but not when C++/Interop starts Excel. Same thing when starting Excel from a VBScript.) Is there a way to get Interop/Excel to pull in or execute a macro from a separate worksheet? Is it possible to get around the security limitation so global macros are available via Interop-invoked Excel? Is there something aside from Interop that I should use to fire up Excel and get this macro running? One thought was to import an existing Excel document with the macro already in it and then run the macro, but I can't find a way to import into a worksheet. If it helps, my configuration is: C++ Net Standard Edition, Excel 2000 Professional, all on Windows XP Home Edition. The C++ app is a CDialog window. Thanks very much for any advice! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automating Macros for CSV files
I don't use C++ at all, but you can change step 2 to open that addin/workbook:
workbooks.open filename:="C:\yourpath\youraddin.xla" Then you'll have access to the routines in that addin/workbook. griffin_5338 wrote: Been all over the 'net looking for an answer to this one, here goes.... I need to collect data in a C++ Net application, then from that same application automatically (with no keys pressed) do the following: 1) Save the file as an Excel-compatible dataset (I chose CSV for its simplicity) 2) Fire up Excel and load up the dataset into a worksheet 3) Execute a very extensive macro (over 800 lines) in Excel - this macro can be installed as a global macro e.g. XLstart directory (see note below) as a separate file or worksheet (optional) 4) Leave the focus on the Excel window so the results will appear foremost to the user Seems simple, and I've had success with steps 1 and 2 using the Microsoft::Office::Interop method. HOWEVER, when Excel is started from my C++ application, none of the global macros are available. This seems to be some kind of security limitation of global macros. Yes, I tried all four security settings to no avail. (If you fire up Excel by itself, global macros in XLStart are available -- but not when C++/Interop starts Excel. Same thing when starting Excel from a VBScript.) Is there a way to get Interop/Excel to pull in or execute a macro from a separate worksheet? Is it possible to get around the security limitation so global macros are available via Interop-invoked Excel? Is there something aside from Interop that I should use to fire up Excel and get this macro running? One thought was to import an existing Excel document with the macro already in it and then run the macro, but I can't find a way to import into a worksheet. If it helps, my configuration is: C++ Net Standard Edition, Excel 2000 Professional, all on Windows XP Home Edition. The C++ app is a CDialog window. Thanks very much for any advice! -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Automating Excel (Macros) | New Users to Excel | |||
Automating swnding mails using macros on Excel. | Excel Worksheet Functions | |||
Pulling files in using Macros | Excel Programming | |||
Automating the depressing of ENABLE MACROS popup | Excel Programming | |||
automating chart generation from text files | Excel Programming |