+ Reply to Thread
Results 1 to 3 of 3

Using VBA to rename and save workbook as cell value

  1. #1
    Registered User
    Join Date
    01-22-2017
    Location
    San Diego, California
    MS-Off Ver
    2010
    Posts
    4

    Using VBA to rename and save workbook as cell value

    Hello,

    I am trying use VBA to rename a file as a cell value, and then save it to a folder on my desktop. The below code is what i have, but i get an the "Compile error: Invaid or unqualified reference" error. I am new to macros/vba and cant see the error. I get this error for most of the code i have pulled from the internet to do this and don't know what i am doing wrong.

    Application.DisplayAlerts = False ' suppress overwrite warning message
    ActiveWorkbook.SaveAs Filename:="C:\Users\Ryan\Desktop\test" & Range("Y1"), _
    FileFormat:=(.xlsm), _
    CreateBackup:=False
    Application.DisplayAlerts = True
    ActiveWorkbook.Close SaveChanges:=False

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using VBA to rename and save workbook as cell value

    Just a guess in the absence of the workbook but should there be a path separator after "test"?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Using VBA to rename and save workbook as cell value

    I think the problem is here
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Not 100% sure about the enumerated constant, but you could check https://msdn.microsoft.com/en-us/lib.../ff198017.aspx
    If you are pleased with a member's answer then use the Star icon to rate it.

+ 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] Copy a sheet, rename it by value in range then export product to new workbook and rename
    By MagicMan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2015, 07:24 PM
  2. Replies: 0
    Last Post: 02-06-2015, 04:50 PM
  3. my save/send macro needs to rename workbook after a cell value
    By VectorW2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-04-2013, 02:45 PM
  4. Copy Workbook, Save and Rename
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-16-2012, 08:04 AM
  5. Replies: 0
    Last Post: 04-28-2012, 06:06 PM
  6. Rename and save file to path based on cell info
    By cabinetguy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-07-2010, 12:38 PM
  7. Rename a workbook and save to another location
    By Sam I Am in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2008, 08:06 PM

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