+ Reply to Thread
Results 1 to 8 of 8

Referencing filename in a saveas function

Hybrid View

  1. #1
    Registered User
    Join Date
    10-01-2007
    Posts
    9

    Referencing filename in a saveas function

    I have several hundred spreadsheets that have some minor editing (removing columns and such) that is the same across the board. I had no problems getting a macro setup to do this. Then I thought rather than saving every file manually with "Revised" after the filename, I could build this into the macro.

    The problem is, I don't know how to get the filename in as a variable. Everything I have seen has referenced the file name as a static, or worse yet, user inputtable value. Yikes!

    While we are on the subject, what is needed to get the macro sets up so it opens a file, runs through the steps, saves, closes, and moves on to the next in the directory?
    Last edited by VBA Noob; 10-01-2007 at 11:04 AM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    If you looping through workbooks maybe

    ThisWorkbook.Name
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    10-01-2007
    Posts
    9
    Quote Originally Posted by VBA Noob
    If you looping through workbooks maybe

    ThisWorkbook.Name
    VBA Noob
    Soooooooo...
    ActiveWorkbook.SaveAs = ThisWorkbook.Name & "Revised"
    I think I am missing something here...

  4. #4
    Registered User
    Join Date
    10-01-2007
    Posts
    9
    When I try above, it generates "Compile Error: Expected Function or variable".

    See attached error screen... thoughts?
    Attached Images Attached Images
    Last edited by Mechroneal; 10-01-2007 at 01:47 PM.

  5. #5
    Registered User
    Join Date
    10-01-2007
    Posts
    9
    New error screen added.

  6. #6
    Registered User
    Join Date
    10-01-2007
    Posts
    9
    Anybody? I know this is close, but I have no idea what I am not doing right here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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