+ Reply to Thread
Results 1 to 5 of 5

Macro to Save a PDF in folder by month

  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:
    Please Login or Register  to view this content.
    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
    Please Login or Register  to view this content.
    and inserted it as
    Please Login or Register  to view this content.
    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

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to Save a PDF in folder by month

    Hi, Tom,

    maybe like this
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

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

    Re: Macro to Save a PDF in folder by month

    Thanks Holger for your reply.

    I get a runtime error 1004 - document cannot be saved. document maybe open or an error may have been encountered when saving.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to Save a PDF in folder by month

    Hi, Tom,

    1004 is the worst documented error in Excel VBA to my taste - it could mean about anything, and definitely nothing in specific.

    How does the date in Range("G13") look like - that could be one issue. Is the name of the folder Apr if it´s today´s date in G13? Do you have rights to write to the folder? Trusted Location? I altered the path for my computer and the file was saved like I expected it to be:
    Please Login or Register  to view this content.
    Ciao,
    Holger

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

    Re: Macro to Save a PDF in folder by month

    Hi Holger,

    Problem solved. Simply it was a trusted location issue. I would never have thought of that. Knew it would be something silly in the end.

    Thanks for your time.

    Tom

+ 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