Results 1 to 5 of 5

Macro to Save a PDF in folder by month

Threaded View

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    Manchester
    MS-Off Ver
    Excel 365
    Posts
    10

    Macro to Save a PDF in folder by month

    Hi all,

    Thanks in advance for your time and apologies if there is a similar post somewhere with in the forum. I've searched around but can't seem to find what I'm looking for.

    I was to save my worksheet as a PDF in a folder based on the month in a specific cell. I've previously acheived this but can't for the life of me figure out how I managed it. The worksheet got corrupted and I had to start again.

    Here is my current code:
    Sub SaveInvAsPDF()
        Dim NewFN As Variant
        ' Copy Invoice to a new workbook
        NewFN = "D:\...\inv" & Range("G15").Value & " - " & Range("A14").Value & ".pdf"
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=NewFN, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=True
        NextInvoice
    End Sub
    Basically, I want it to save in a folder based on a month in a date cell (G13) with the actual file name being "inv 'G15' - 'A14'.pdf" The save name bit currently works but I can't seem to get it to save in the specific folder, which are already generated, if that makes sense.

    I've tried something similar as
     Dim GetMonth As Variant
    GetMonth = Range("G13").Value Format(Date,"mmm")
    and inserted it as
     NewFN = "D:\...\inv\" & GetMonth & "\" & Range("G15").Value & " - " & Range("A14").Value & ".pdf"
    but it saves to a different location with the file name as either "False.pdf" or "invFALSE.pdf"

    Any help is much appriciated.

    Cheers

    Tom
    Last edited by tomisthereason; 04-23-2013 at 01:09 PM. Reason: wanted to use code tags

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