+ Reply to Thread
Results 1 to 2 of 2

What is the syntax to save a file to the working directory with VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    01-18-2012
    Location
    Los Angeles USA
    MS-Off Ver
    Excel Office 365
    Posts
    80

    What is the syntax to save a file to the working directory with VBA

    I am running some code to save a worksheet to its own excel file. What is the syntax to allow the path to be generic, to save the file to the working directory, where the excel workbook file is located. In this example the workbook is in the directory "Excel Dashboard". What if the directory I want to save to is one folder below the working directory, "Excel Dashboard\Invoices"?

    Sub SaveInvWithNewName()
        Dim NewFN As Variant
        ActiveSheet.Copy
        NewFN = "D:\Documents\Dropbox\Excel Dashboards\Inv" & Range("F3").Value & ".xlsx"
        ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
        ActiveWorkbook.Close
        NextInvoice
    End Sub
    I am writing the program on Win 7, but it will also be used on a Mac, will the syntax for the path need to be different?

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: What is the syntax to save a file to the working directory with VBA

    I'm afraid your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

+ 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