Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA + VB Script fails to open the workbook.
Hi all,
I use the following VB Script to open an XLA and execute a macro. Dim objxl, xlapath, macro Set objxl = CreateObject("Excel.Application") xlapath = "C:\myxla.xla" macro="myxla.xla!macro1(""param1"",""param2"")" With objxl .Visible = True .Workbooks.Open xlapath .Workbooks("myxla.xla").RunAutoMacros 1 'xlAutoOpen .Run macro End With Within the xla-macro, I try to open another workbook. Public Sub macro1(param1 As String, param2 As String) Dim wb As Workbook Dim url As String url = "http://localhost/test.csv" Debug.Print "Attempting to open : " & url Set wb = Workbooks.Open(Filename:=url, UpdateLinks:=False, ReadOnly:=True, Editable:=False, AddToMru:=False, Format:=1) If wb Is Nothing Then Debug.Print "Could not open the page: " & url else Debug.Print "Successfully opened : " & url End If End Sub This macro works if I invoke it from VBA. But doesnot work (the workbook is never opened, and wb Is Nothing), if I invoke it using the VB Script. Could someone please tell me what I am doing wrong ? Is there a better way to do this ? Thanks in advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Script fails in Excel was okay before. | Excel Programming | |||
Workbook fails to open - Excel 2003 | Excel Discussion (Misc queries) | |||
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. | Excel Programming | |||
Excel fails to open workbook using Automation from VB 6 | Excel Programming | |||
Sheets select method fails when workbook is opened by another workbook | Excel Programming |