+ Reply to Thread
Results 1 to 10 of 10

VBA for Exporting to PDf

  1. #1
    Registered User
    Join Date
    04-10-2023
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Office 365
    Posts
    5

    VBA for Exporting to PDf

    I need a VBA code to save a worksheet as the current file name and export to PDF. The code below is what I got when I recorded this action. The problem is that the file path and file name will change monthly, so I need it to be for the current path & name. How do I modify this code to do that?

    Sub PDFExport()
    '
    ' PDFExport Macro
    ' To save AIA Line Breakout to PDF as billing summary sheets for backup file.
    '

    '
    ChDir _
    "H:\001 Monthly Billings\2023\02 FEBRUARY 2023\001 CINFAB\UC Health\002 SI Infill"
    ActiveWorkbook.SaveAs Filename:= _
    "H:\001 Monthly Billings\2023\02 FEBRUARY 2023\001 CINFAB\UC Health\002 SI Infill\SI INFILL FEBRUARY 2023 LABOR & MATERIAL DETAILS.xlsm" _
    , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    ActiveWindow.Close
    End Sub

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: VBA for Exporting to PDf

    Use something similar to the routine I use in the attached QuoteList app.
    To demo first select two or three items from the upper list - then press the 'Qty' header label to totalise - press Save/Print - a dialogue box appears, you can now name your file and save to anywhere you choose.
    Attached Files Attached Files
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    04-10-2023
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Office 365
    Posts
    5

    Re: VBA for Exporting to PDf

    Thank you for the response, but I cannot try the demo you sent me because my company has the macros blocked. From your description, it does not sound like what I am looking for. The path and name will change every month, so I need the code to use the current name and path without being anchored to a specific workbook like my current code. This macro will be grouped with several others in a button, so that I can just click the button and everything will be automated. It should not require any input from the user.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: VBA for Exporting to PDf

    Or
    Please Login or Register  to view this content.
    Experience trumps academics every day of the week and twice on Sunday.

  5. #5
    Registered User
    Join Date
    04-10-2023
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Office 365
    Posts
    5

    Re: VBA for Exporting to PDf

    Quote Originally Posted by jolivanes View Post
    Or
    Please Login or Register  to view this content.
    Thank you for the quick response. This partially worked. It saved the PDF, but not the Excel file like the "Save As PDF" function does. Also, when I tried to open the PDF, it gave me an error about it being corrupted because of the way it was created.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: VBA for Exporting to PDf

    Don't quote whole posts. Refer to a post number and/or particular poster.
    It creates nothing but not needed clutter.

  7. #7
    Registered User
    Join Date
    04-10-2023
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Office 365
    Posts
    5

    Re: VBA for Exporting to PDf

    Quote Originally Posted by jolivanes View Post
    Don't quote whole posts. Refer to a post number and/or particular poster.
    It creates nothing but not needed clutter.
    I am sorry my reply bothered you. But, if that is a rule of this forum, then it should not have a button that says "Reply With Quote". It would also have been nice if your reply would have included some helpful information that actually pertained to my post so that it was not a complete waste of time for me to come here to read your reply.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: VBA for Exporting to PDf

    Did I hit a nerve?

    Re: "it was not a complete waste of time for me to come here to read your reply."

    You must be a high up VIP. Sorry to have even attempted to help you.
    I have the working code but I won't bother you with it in case you have to waste your time and, who knows, not like it.
    Good luck with your high and mighty attitude for the rest of your important life.

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: VBA for Exporting to PDf

    @ssmith3156, I find it faintly amusing that your company blocks macros when by inference in post#3 you state the use of a macro on a button, if your IT department are able (if they have the expertise) they could check the safety of the macro and may be learn from it, however surely they should be able to solve this without recourse to a help forum.

  10. #10
    Registered User
    Join Date
    04-10-2023
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Office 365
    Posts
    5

    Re: VBA for Exporting to PDf

    I said they blocked the macros on that file. They were blocked because it was from an unknown source. We do not have an IT department, just one IT person. This is not in his wheelhouse. His job is to keep the company connected and all tech running smoothly and efficiently. Daily usage of the software programs is not part of his responsibilities, therefore he has no reason to learn complex features of the applications. Thank you for your attempt to help. Have a great day!

+ 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] exporting CSV from IE
    By kiwi_boer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-25-2017, 10:56 PM
  2. [SOLVED] Exporting to JPG.
    By Johnny0811 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-28-2017, 06:32 AM
  3. Need help exporting to .txt with no tab
    By connelluk in forum Excel General
    Replies: 2
    Last Post: 07-16-2014, 03:45 AM
  4. Exporting to PDF
    By Keeper00 in forum Excel General
    Replies: 4
    Last Post: 04-23-2014, 11:31 AM
  5. Exporting as XML
    By meh2424 in forum Excel General
    Replies: 0
    Last Post: 02-09-2011, 05:01 PM
  6. Exporting
    By jabryantiii in forum Excel Programming / VBA / Macros
    Replies: 41
    Last Post: 01-20-2010, 09:03 PM
  7. exporting to ACT!
    By rmaxson1104 in forum Excel General
    Replies: 3
    Last Post: 06-24-2007, 07:52 PM

Tags for this Thread

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