Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Command Fails (Word 2003)

    I use the attached macro to create a second document based on information from the first document. I get a command failed error at the point when I am trying to name the second document which has the same filename as the first, except with an XML extension saved as a Text file. These are NOT true XML files, they simply have tags formatted like XML tags, but the client requires the XML extension.

    If someone can add insight as to why the document naming process fails, I would appreciate it.

    Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Command Fails (Word 2003)

    You declare a variable strDocNam and use that in the first Save As instruction. In the last instruction, however, you use strDocName which hasn't been declared.

    BTW, this makes me suspect that you haven't set Require Variable Declaration in Tools | Options... (in the Visual Basic Editor). If you do that, you'll get a line Option Explicit at the top of every new module you create. If you had Option Explicit in your module, you would get an error message that strDocName has not been defined.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Command Fails (Word 2003)

    Thanks, Hans! I have looked at this for a week and can't believe I missed that. Also, I appreciate the info about the option explicit info. I will definitely use that feature.

    Once again, you saved my day!

Posting Permissions

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