Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to close and re-open excel for macro to fire
Message
From
13/08/2007 12:29:45
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Need to close and re-open excel for macro to fire
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01247849
Message ID:
01247849
Views:
68
Hi all,

I have certain spreadsheets that are created programatically through VFP, which are originally created from basic templates which contain macros, which all the new spreadsheets inherit. These macros also play a part in populating the cells.

Now I face a unique problem. After creating/opening an excel file through VFP, and creating a new sheet in a spreadsheet using a macro called CreateSheet (below), I need to save,close and reopen the file, in order for the other macros to fire. Otherwise they do not fire!

This process can take upto 30 seconds extra!

My code, below
oExcel=GetObject(,"Excel.Application")

WITH oexcel
   .Run("Macrofile.xls!CreateSheet")				
   .Activeworkbook.save
   .Activeworkbook.close && closing and reopening to secure  all data
   .workbooks.open('c:\devstudio\panorama\'+lcgang+'.xls')
   .Run("Macrofile.XLS!NewSheetName")
   DO Prgfillsheet
ENDWITH
Thanks in advance,

Regards,

Steve
Next
Reply
Map
View

Click here to load this message in the networking platform