+ Reply to Thread
Results 1 to 7 of 7

The parameter is incorrect - doc.Save sFile

  1. #1
    Registered User
    Join Date
    02-02-2016
    Location
    Sparkford, England
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    7

    The parameter is incorrect - doc.Save sFile

    I've written my first VBA macro to export data from XLS to a named XML file. My initial, simplified tests went fine but the full version errors with the message:

    Run-time error '-2147024809 (80070057)':
    The parameter is incorrect

    and the line 'doc.Save sFile' is highlighted.

    Can anyone help?

    NOTE: I had to post the code as a Word file attachment because the site thinks it contains HTML.

    Sub OrdXMLExport.docx

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: The parameter is incorrect - doc.Save sFile

    What is the value of sFile when it errors?

  3. #3
    Registered User
    Join Date
    02-02-2016
    Location
    Sparkford, England
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    7

    Re: The parameter is incorrect - doc.Save sFile

    The file names are in the first column of the XLS doc and follow the format ord_EB100.log. No path is specified because I want the XML saved in the same folder.

  4. #4
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: The parameter is incorrect - doc.Save sFile

    Quote Originally Posted by StephenR View Post
    What is the value of sFile when it errors?
    It is not assigned a value in the code posted. So blank, which would cause an error.
    Last edited by grimes0332; 02-02-2016 at 08:51 AM.

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: The parameter is incorrect - doc.Save sFile

    Bingo.......

  6. #6
    Registered User
    Join Date
    02-02-2016
    Location
    Sparkford, England
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    7

    Re: The parameter is incorrect - doc.Save sFile

    This is my first bit of VBA... How, and where, do I assign a value to the sFile?

  7. #7
    Registered User
    Join Date
    02-02-2016
    Location
    Sparkford, England
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    7

    Re: The parameter is incorrect - doc.Save sFile

    Thanks for your help. Aware that a value had to be declared somewhere I had a careful look through the code (and the XLS doc) and found the error. That particular part of the VBA script was missing 'sFile = .Cells(lRow, 1).Value'.

    Now sorted.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Saving excel sheets to folder - problem with Dim sFile ect
    By k1989l in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2016, 08:11 AM
  2. Replies: 2
    Last Post: 10-06-2014, 08:15 AM
  3. Calculation table - change 1 parameter and save data
    By dourpil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-30-2014, 06:51 AM
  4. [SOLVED] Set default Save-As parameter to Macro Enabled workbook
    By JimDandy in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-24-2013, 09:26 AM
  5. Save path is incorrect
    By TomTom_BV in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-27-2009, 05:12 AM
  6. The parameter is incorrect
    By overcanyon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2006, 03:00 PM
  7. What parameter changes upon new workbook Save?
    By G Lykos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1