Invalid Procedure Call Or Argument with VBScript

O

okcodeyoda

Hi,

I'm using VBScript to open an Excel document provided by a user and
exporting a gridview's contents to that Excel document. This process
works flawlessly on the first export, but if the user saves the
resulting Excel document, they can NEVER again use for an export from
this intranet website.

The code I'm using to export is:

Dim sHTML, oXL, oBook, oBook2, STHML2
Set oXL = Nothing
Set oBook = Nothing
Set oXL = CreateObject("Excel.Application")

dim filePath
filePath =
document.all.item("ctl00_ContentPlaceHolder1_Tabs_tpExport_fuTemplate").value

sHTML =
document.all.item("ctl00_ContentPlaceHolder1_resultGrid").outerhtml
Set oBook = oXL.Workbooks.Open(filePath)

oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML

oBook.HTMLProject.RefreshDocument

'oXL.Visible = true
'oXL.UserControl = true
oXL.Quit()


I've purposely left out the oXL.Visible = True and oXL.UserControl =
True lines so that the user is not presented with the resulting Excel
document automatically...but this does not change the outcome.

Another odd aspect is that if you use Set oBook =
oXL.Workbooks.Add(filePath) when the user goes to save the resulting
Excel document he is given a save dialog with the provided filePath
with a '1' appended to the end. If this document is saved, the user
can then proceed to save to the ORIGINAL filePath without incident.

Thanks in advance for any assistance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top