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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to open an Excel file w

Status
Not open for further replies.

kpal29

Technical User
Feb 8, 2003
147
DK
I am trying to open an Excel file w/ a macro so that I can run the macro when I export my query out of Access to Excel, I want the following to happen:

1. Open the wkbk containing my macros minimized
2. Export the query to a new workbook (this is working w/ the transferspreadsheet command)
3. Maybe use Sendkeys to run the macro in on the new file.

I tried using code with " new excel.application and I keep getting this error:Compile Error: User-defined type not defined and the New Excel.appliation is the line that is highlighted.

I have Access 10.0 object library and DAO 3.6
I tried adding Excel 10.0 but it gave me an error conflicting references. How do I make this work?
 
try doing this in a module:

Call Shell("fullpath\excel.exe path/filename.xls", 1)

where fullpath\excel.exe is the full path and filename of your excel program and path/filename.xls is the macro file you want to run and your macro should be named Auto_Open in the file. (To edit a file with an Auto_Open macro, you must hold down the shift key when you open it or the macro will execute upon opening)

Here's an example:
Call Shell("c:\office2k\office\excel.exe \\90.13.164.169\Business\Scheduled_Reports\Weekly-282614-PMPT\Datafiles\final.xls ", 1)






Trisha
padinka@yahoo.com
 
kpal29,

I think if you do not add the excel references then Dim ... as new excel.application will not work. you could try doing this:

Dim xlObj as object
set xlObj = CreateObject("Excel.Application")

this object should have access to all excel properties and methods. good luck
 
Excellent! That worked great. Now after the macro file opens, then an invoice is exported from access and automatically opened in Excel.

At this point there are 2 workbooks open, the macro and the newly created invoice. The newly created window now has focus.

How can I call the macro I need to run from Access?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top