+ Reply to Thread
Results 1 to 2 of 2

Use VBA to save document as

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    Netherlands
    MS-Off Ver
    Microsoft Excel 365
    Posts
    62

    Use VBA to save document as

    Dear,

    I'm trying to use VBA to save multiple documents in different directories depending on values in cells. Below, I only show the relevant lines.

    Unfortunately, I haven't saved any file yet. To check: I use VBA to print "OK" in different cells after performing a new line of code. All are printed except the one in H1. Any ideas what is going wrong? Many thanks

    Dim path As String
    Dim FileName As String

    Range("E1") = "OK"
    path = Range("H12").Value
    Range("F1") = "OK"
    FileName = Range("F12").Value
    Range("G1") = "OK"
    wb2.SaveAs FileName = path & FileName, FileFormat = xlNormal
    Range("H1") = "OK"

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Use VBA to save document as

    You should use the macro recorder to record yourself opening a file and saving it in a new location.

    You will get something like this.

    Please Login or Register  to view this content.

    If you use

    InstrRev you can strip out the Filename and the path name

    Please Login or Register  to view this content.

    Alternatively you could use these functions:-

    Please Login or Register  to view this content.

+ 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. How Do I un save a document
    By piczim in forum Excel General
    Replies: 2
    Last Post: 04-16-2013, 01:52 PM
  2. Replies: 0
    Last Post: 11-22-2012, 08:42 AM
  3. you must save document as something else
    By NinjaBear in forum Excel General
    Replies: 3
    Last Post: 11-22-2011, 08:52 AM
  4. 'document not saved' for 'save' or 'save as' an EXCEL file
    By Judy Chuang in forum Excel General
    Replies: 1
    Last Post: 07-11-2005, 06:05 PM
  5. document did not save
    By gustavog in forum Excel General
    Replies: 2
    Last Post: 05-31-2005, 08:35 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