+ Reply to Thread
Results 1 to 7 of 7

Macro - Save Word as PDF with Unique Name and Email PDF to specified email address.

  1. #1
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Macro - Save Word as PDF with Unique Name and Email PDF to specified email address.

    Hi All,

    I have a Word Document, which I need macro to save as PDF.
    I have the following code to save as PDF.

    I need to tweak the code to save the PDF with a Unique File Name.

    This is the format of the File name : <UserName>_<Serial>_<Date>.pdf

    The issue is this, the fields that i have mentioned are actually Linked to an Excel Sheet. So how am i suppose to reference it into my code? Im not sure on how to proceed with this.

    Also I need help in emailing this PDF in Outlook to 2 email address. Anyone able to share some code on this. Thank you.

    Sample of my Word Document Attached.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Macro - Save Word as PDF with Unique Name and Email PDF to specified email address.

    The naming & saving is easily handled with:
    Please Login or Register  to view this content.
    For the sending of the emails, I suggest you do a web search on that aspect of VBA. There are plenty of links with demo code.

    PS: Unless you have some particular reason for using the ExportAsFixedFormat method, I'd suggest you consider using the SaveAs method.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: Macro - Save Word as PDF with Unique Name and Email PDF to specified email address.

    Quote Originally Posted by macropod View Post
    The naming & saving is easily handled with:
    Please Login or Register  to view this content.
    For the sending of the emails, I suggest you do a web search on that aspect of VBA. There are plenty of links with demo code.

    PS: Unless you have some particular reason for using the ExportAsFixedFormat method, I'd suggest you consider using the SaveAs method.
    Thank You sir on the code.. I have test it out..

    But my output PDFfilename is showing as this : Test_Department_User.Secretary_User.LineManager.pdf instead of <UserName>_<Serial>_<Date>.pdf

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Macro - Save Word as PDF with Unique Name and Email PDF to specified email address.

    It is not clear from your document with table row is required row 4 is the first with links in all cells. If you want to use another row, change the '4' in .Rows(4) to whatever else you think it should be. I'd have thought that would be very obvious to anyone who bothered to read to code instead of just copying & pasting it without giving any thought to it.

  5. #5
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: Macro - Save Word as PDF with Unique Name and Email PDF to specified email address.

    Quote Originally Posted by macropod View Post
    It is not clear from your document with table row is required row 4 is the first with links in all cells. If you want to use another row, change the '4' in .Rows(4) to whatever else you think it should be. I'd have thought that would be very obvious to anyone who bothered to read to code instead of just copying & pasting it without giving any thought to it.
    My apologies for mentioning, as Im still trying my best to learn coding. If you can see for the PC s/n - which is the serial im referring to be captured in the file name. I had actually split the cells, so will this affect the way i should reference cell? Please advise

  6. #6
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: Macro - Save Word as PDF with Unique Name and Email PDF to specified email address.

    Tweaked the code around and got it working

    Please Login or Register  to view this content.

  7. #7
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Macro - Save Word as PDF with Unique Name and Email PDF to specified email address.

    Try:
    Please Login or Register  to view this content.
    As mentioned in my initial reply, I've simplified the save process.

+ 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. Macro to create unique id from email address and assign to repeated entries
    By capson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2014, 11:26 PM
  2. Macro to PDF a sheet in workbook and email (outlook) to an email address in a cell
    By paul_sykes00 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-17-2012, 12:54 AM
  3. Replies: 6
    Last Post: 12-02-2011, 02:14 PM
  4. Macro to move word document based on email address
    By kingsley in forum Excel General
    Replies: 0
    Last Post: 10-03-2011, 02:25 PM
  5. Macro doesn't automatically resolve All email address when email is drafted
    By sonny.thind in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2011, 12:58 PM

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