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

launching Excel with Auto_open macro from .HTML

Status
Not open for further replies.

camjai

Programmer
Jul 26, 2004
17
NL
Hello,

im using a VB script to launch an .xls (excel) file. This works fine except for one excel file that should run an Auto_open macro when launched. It does run perfectly when launched from the windows explorer but won't run when launched via the VB script. I can run the macro from the Excel menu after opening the file with the VB script but it won't Auto run.

Any ideas?

My script:
<script type=text/vbscript>
<!--
Function sjabloonxls(waarde)
Dim objexcel
Dim waarde2
Set objexcel = CreateObject("Excel.Application")
objexcel.Quit
Set objexcel = Nothing
Set objexcel = CreateObject("Excel.Application")
objexcel.Visible = True
objexcel.WindowState = 1
waarde2 = "G:\data\HIP\IGG\sjablonen\" + waarde
Set mijndocument = objexcel.Workbooks.Add(waarde2)
Set objexcel = Nothing
Set mijndocument = Nothing
End Function
-->
</script>

thanks.
 
instead of...
Code:
Set mijndocument = objexcel.Workbooks.Add(waarde2)
Set objexcel = Nothing
Set mijndocument = Nothing
try...
Code:
[s]Set mijndocument =[/s]objexcel.Workbooks.[b]Open[/b](waarde2)
Set objexcel = Nothing
[s]Set mijndocument = Nothing[/s]

Tony
________________________________________________________________________________
 
thanks for the help Fester but someone on a different forum pointed me towards the answer. It appears Auto_open macros never work when you open the excel file from a VB(A) script. Instead you have to hard code the running of the macro.

I got it to work by adding this line to my script:

objexcel.Run "Auto_open
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top