Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    1

    Angry Unanswered: SaveAs method of Workbook class failed

    Stupid job, actually. Every day I have to connect to certain server, get an XLS file, open it, save as HTML and upload to web server. Source filename is always the same. To cut it short, the VBS I am working on simply doesn't do it - it returns the "SaveAs method of Workbook class failed" error. And I am really lost here!
    I know it's not ASP code, but it's very similar.

    Here's the script:

    -----START------
    set filesys=CreateObject("Scripting.FileSystemObject")
    pathstring = filesys.GetAbsolutePathName(".")
    pathstring=pathstring & "\"
    file = InputBox("Filename,without the extension","Enter")

    Set xl = CreateObject("Excel.Application")
    xl.visible = false
    xl.WorkBooks.Open pathstring & file & ".xls"
    xl.ActiveWorkbook.SaveAs pathstring & file & ".htm", xlHTM
    xl.ActiveWorkbook.Close
    xl.quit
    -----END------

    The one MsgBox asks (for the testing purposes) for the filename. The script and the XLS file both exist on my Desktop (same folder), and so should the HTM file, too.

    Thanx!

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Okie, I haven't tried this before but a couple of thoughts that might help.....

    Does the htm file already exist?? Are you attempting to write over an existing file.

    I have been looking at some examples online and the method call seems slightly different... particularly the specification of the file format... they tend to use something like Excel.XlFileFormat.xlHtml

    check out this link.... http://msdn.microsoft.com/library/de...eworkbooks.asp

    Hope that helps....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •