+ Reply to Thread
Results 1 to 16 of 16

PDF Macro - PLEASE HELP!!!

  1. #1
    Registered User
    Join Date
    06-29-2012
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    14

    PDF Macro - PLEASE HELP!!!

    Hi -

    I have a macro that will create a PDF file for archival purposes. I can get the macro to work fine, however I want to refer to a specific cell to include a name in the PDF file.

    For example, currently, the macro will produce a PDF file called "CARE/PDF" I want to alter the macro to include a name in PDF file name, like "FRED_CARE.PDF". The name fred appears in cell b4 of the "CARE" worksheet.

    This is what I have:

    ' MakePDF Macro
    '
    ' Keyboard Shortcut: Ctrl+a
    '
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "F:\HOME\COMMERCIAL\SMALL GROUP RATE MODELS\PDF Files\Care.pdf", Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True
    End Sub

    Can anyone please help me??

    Thanks,

    JB

  2. #2
    Forum Contributor
    Join Date
    06-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: PDF Macro - PLEASE HELP!!!

    Will the name in B4 change? If not just put the name you want for care. You could also just run the command to close the file and it will prompt the user to Save.

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "F:\HOME\COMMERCIAL\SMALL GROUP RATE MODELS\PDF Files\Name_Care.pdf", Quality:= _

  3. #3
    Registered User
    Join Date
    06-29-2012
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: PDF Macro - PLEASE HELP!!!

    That is the problem, it can change!

  4. #4
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: PDF Macro - PLEASE HELP!!!

    Change the file name argument to:
    Please Login or Register  to view this content.
    Post responsibly. Search for excelforum.com

  5. #5
    Registered User
    Join Date
    06-29-2012
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: PDF Macro - PLEASE HELP!!!

    I tried changing it but get an error that says - Compile Error: Syntax Error......

  6. #6
    Registered User
    Join Date
    05-13-2010
    Location
    Kozhikode, Keral, India
    MS-Off Ver
    Microsoft Office home and student 2019
    Posts
    49

    Re: PDF Macro - PLEASE HELP!!!

    You should try this and please let us know!
    Please Login or Register  to view this content.
    Last edited by Chandrajit; 06-29-2012 at 03:09 PM. Reason: code edit
    Best Regards
    Chandrajit

  7. #7
    Forum Contributor
    Join Date
    06-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: PDF Macro - PLEASE HELP!!!

    HTML Code: 

  8. #8
    Registered User
    Join Date
    06-29-2012
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: PDF Macro - PLEASE HELP!!!

    I made the change but cannot get it to work.......very frustrating.....

    I get a runtime error 438 Object doesnt support this method or property....

  9. #9
    Registered User
    Join Date
    05-13-2010
    Location
    Kozhikode, Keral, India
    MS-Off Ver
    Microsoft Office home and student 2019
    Posts
    49

    Re: PDF Macro - PLEASE HELP!!!

    tried this?
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-29-2012
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: PDF Macro - PLEASE HELP!!!

    Quote Originally Posted by Chandrajit View Post
    tried this?
    Please Login or Register  to view this content.
    Yes, I did try that

  11. #11
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: PDF Macro - PLEASE HELP!!!

    this one it works fine, did not tried the other one!
    please chg the path
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  12. #12
    Registered User
    Join Date
    06-29-2012
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: PDF Macro - PLEASE HELP!!!

    I tried this but can't get it to work......here is the code I am using:

    On Error Resume Next
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "F:\HOME\COMMERCIAL\SMALL GROUP RATE MODELS\PDF Files\" & ThisWorkbook.Sheets("Rate Sheet Plan Year").Range("B3") & "_ Plan_Year.pdf", Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True
    End Sub

    Please note that I did change the sheet and range intentionally!

    Thanks!!

  13. #13
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: PDF Macro - PLEASE HELP!!!

    I suggest you to test the code, let's say on yr desktop, and then change the path for yr needs. also, take care of yr sheet name!

  14. #14
    Registered User
    Join Date
    06-29-2012
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: PDF Macro - PLEASE HELP!!!

    Thanks, John.
    I still cannot get this to work. What is wrong with the sheet name?
    JB

  15. #15
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: PDF Macro - PLEASE HELP!!!

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.


  16. #16
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: PDF Macro - PLEASE HELP!!!

    do you rcv any error?
    @zbor, I am sorry, I did not refresh the page, please delete my post!
    thx!

+ 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