Exel Macro

Geoffk

Registered User.
Local time
Tomorrow, 03:19
Joined
Feb 24, 2007
Messages
22
I have used this code which was submitted by Anthony George to open an Exel worksheet

Private Sub Command16_Click()
On Error GoTo Err_Command16_Click

'Dimension the Variables
Dim xlApp As Excel.Application
Dim xlWkbk As Excel.Workbook
Dim xlSht As Excel.Worksheet

'Set the application
Set xlApp = New Excel.Application

'Make the Application Visible
xlApp.Visible = True

'Set the workbook and the filepath 'Change "C:\Book1.xls " to your own filepath and Workbook name
Set xlWkbk = xlApp.Workbooks.Open("C:\PTVC\Routing\CustMacro.xl s ")

'Set the worksheet that you want the workbook to open on
xlApp.Sheets("Sheet3").Select

'Turn everything off otherwise yo will have problems with your spreadsheet
Set xlApp = Nothing
Set xlWkbk = Nothing
Set xlSht = Nothing

Exit_Command16_Click:
Exit Sub

This works fine, for wich I thank you Anthony, my problem is that I have a macro to transpose the workbook called Auto_Open which auto runs when workbook CustMacro.xls opens.

The macro runs ok when I open the workbook from MS access using a Hyperlink and when I open it directly, when I run your code it opens the workbook but does not run the macro, do you have a solution.

After running the macro I need to import the transposed workbook into MS Access table Customers

Thanks in advance.
Geoffk
 

Users who are viewing this thread

Back
Top Bottom