Results 1 to 2 of 2
  1. #1
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    619
    Thanks
    166
    Thanked 75 Times in 66 Posts

    Word SaveAs current Filename+suffix

    I customize file1.docx with a macro, and want it to SaveAs file1-a.docx;
    Then I reopen file1, customize differently with another macro, and want SaveAs file1-b.docx;
    Repeat 3-4 more times to end up with file1-c.docx, file1-d.docx, file1-e.docx, file1-f.docx

    There are over 100 fileX to deal with, so the 'file1' part can't be hardcoded, it must call the current file's name.
    The suffixes [-a, -b, -d etc] will be hardcoded, they remain the same.

    What's the syntax for the last line of my macros to achieve the SaveAs?

    In English, it needs to do following:
    SaveAs CurrentFileName-a
    SaveAs CurrentFileName-b
    etc.

    I assume I need a variable to 'capture' the current filename, and then use that? Or maybe more likely, Word already has syntax like Active.Document.Name, so I'd use
    SaveAs Active.Document.Name-a
    SaveAs Active.Document.Name-b
    Lugh.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    The property you want is ActiveDocument.Name but you will see that it includes the suffix. To remove that you could use
    Code:
    Split(ActiveDocument.Name,".")(0)
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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