Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Excel macro

Status
Not open for further replies.

EKC

Technical User
Jan 13, 2001
43
CA
Hi,
I need to run Excel macro from my VFP program and I have this code:
oX=CreateObject("EXCEL.APPLICATION")
oX.Visible=.T.
oX.Workbooks.Open("C:\Folder1\WIP.xls")
oX.Run macro1

macro1 is the name of the macro
The last line gives me syntax error!(I tried with oX.Run "macro1")
My question is how to run macro and how to set reference to excel object to Nothing?
Thanks in advance,
Lyn
 
I don't know how to run the macros, but I do have a working excel program and it ends with (oExcel is the object originally created):
Code:
oExcel.quit()
oExcel = .Null.
oExcel(release)
At least in the VFP environment this works. I haven't used the program in a standalone yet.

I was looking for a VBAexcel help file but can't find one offhand on my computer. I know outlook has one, and I'd think Excel would too. Anyone know what it's called and if it's included with Microsoft Office or MSDN Library?
 
Hi Lyn,

If the name of your macro is macro1, use either of the following:

lcMyMacro="macro1"
oX.Run(lcMyMacro)

or

oX.Run("macro1")

DEDMOD,

The name of the VBA excel programming help file for Excel 2000 is VBAXL9.chm. Most Office programming help files match the following file skeleton: VBA*.CHM

Search your hard drive or MSDN library disks or Office2000 disks. Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Actually I've got an older version of Office and I find it's a VBA_xl.hlp file, but for some reason it's not on my computer. I did find it on the Office disks as you suggested, however. Strangely, I do have the VBA_acc.hlp file installed. I remember doing a lot of work with Access a while back, so I guess I must have installed some more stuff for it than the other components.

I got Outlook 2000 not long ago so I do have the .chm for it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top