Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Opening a workbook containing macros from VB

I am trying to open an Excel workbook that contains macros
from Access97 VB. I use the coding:

Set MyExcel = CreateObject("Excel.Application")
With MyExcel
.Workbooks.Open pathname & "Book1.xls"

to open the file, but I keep getting an error that the
method is invalid. Does anyone know how to open an Excel
file that contains macros using VB and be able to enable
the macros and use them? Thanks!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Opening a workbook containing macros from VB

Brian ,

I ran your code, albeit in Excel creating a new instance of Excel, and as
long as I defined a value for pathname it worked fine. That should be the
same as for Access VBA I think you might need to post more code to see the
problem.

This is my code, with a line to run a macro in that workbook.

Dim my As Object
Dim pathname As String

pathname = "C:\myTest\"
Set myExcel = CreateObject("Excel.Application")
With myExcel
.Workbooks.Open pathname & "myFile.xls"
End With
myExcel.Visible = True
myExcel.Run ("test")


--

HTH

Bob Phillips

"Brian Walters" wrote in message
...
I am trying to open an Excel workbook that contains macros
from Access97 VB. I use the coding:

Set MyExcel = CreateObject("Excel.Application")
With MyExcel
.Workbooks.Open pathname & "Book1.xls"

to open the file, but I keep getting an error that the
method is invalid. Does anyone know how to open an Excel
file that contains macros using VB and be able to enable
the macros and use them? Thanks!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Opening a workbook containing macros from VB

Brian,

I guess TransferSpreadsheet is an Access function, and I am not an Access
user I am afraid.

If no-one sorts it in the next couple of days, you could send me the Access
file and I will do my best to look at it.

--

HTH

Bob Phillips

"Brian Walters" wrote in message
...
Thanks for replying Bob!! I don't think it is the opening
of the file that is the problem anymore. I do a
TransferSpreadsheet command to the excel file just before
I open it. It seems as if the TransferSpreadsheet is not
letting go of the excel file and then I try to open it and
I get an automation error.

Here's the code.

Private Sub cmdShow_Click()
DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel97, "OneShowCalcParticipant", wcDir
& "Book1.xls", True
Set MyExcel = CreateObject("Excel.Application")
With MyExcel
.Workbooks.Open FileName:=wcDir & "Book1.xls"
End With
MyExcel.Visible = True
End Sub


-----Original Message-----
Brian ,

I ran your code, albeit in Excel creating a new instance

of Excel, and as
long as I defined a value for pathname it worked fine.

That should be the
same as for Access VBA I think you might need to post

more code to see the
problem.

This is my code, with a line to run a macro in that

workbook.

Dim my As Object
Dim pathname As String

pathname = "C:\myTest\"
Set myExcel = CreateObject("Excel.Application")
With myExcel
.Workbooks.Open pathname & "myFile.xls"
End With
myExcel.Visible = True
myExcel.Run ("test")


--

HTH

Bob Phillips

"Brian Walters" wrote in

message
...
I am trying to open an Excel workbook that contains

macros
from Access97 VB. I use the coding:

Set MyExcel = CreateObject("Excel.Application")
With MyExcel
.Workbooks.Open pathname & "Book1.xls"

to open the file, but I keep getting an error that the
method is invalid. Does anyone know how to open an

Excel
file that contains macros using VB and be able to enable
the macros and use them? Thanks!!



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I stop blank workbook from opening when opening an existing kjg Excel Discussion (Misc queries) 3 February 12th 10 09:36 PM
Excel 09 File containing macros is not opening MAtif Excel Discussion (Misc queries) 2 February 5th 09 02:58 PM
when opening an Excel Workbook, another blank workbook also opens Gord Dibben Excel Discussion (Misc queries) 0 October 12th 07 09:49 PM
when opening an Excel Workbook, another blank workbook also opens spmu Excel Discussion (Misc queries) 0 October 12th 07 01:46 PM
Macros Disabled when opening file snax500 Excel Discussion (Misc queries) 1 October 19th 06 09:37 PM


All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"