+ Reply to Thread
Results 1 to 5 of 5

VBA Macro that converts and saves the worksheet into a PDF & customizing the filename

  1. #1
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    VBA Macro that converts and saves the worksheet into a PDF & customizing the filename

    I am presently using the code below to convert a worksheet into a PDF and then automatically save it to a specified location on a shared drive. The down side to the code below is that it must be modified each year to accomodate for a new FY. I am trying to figure out a different way of saving the file so that the code does not need to be changed each year.

    The year (highlighted in red below) of the file is located in cell "F6" on worksheet "Menu". The date range (also highlighted below) for this particular worksheet is located in cell "B9" of worksheet "Menu". Is there a way to modify the code below so that rather than tell it to save in folder "2012", subfolder "01 = 061911 - 070211", that it would instead look at "F6" and "B9" and know where to save it based on their values?


    Please Login or Register  to view this content.
    Last edited by jonvanwyk; 12-29-2011 at 09:55 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Macro that converts and saves the worksheet into a PDF & customizing the file

    Something like this
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: VBA Macro that converts and saves the worksheet into a PDF & customizing the file

    Thanks for the help Roy. I believe I should have included the code for the macro in its entirety. My post above only included the portion I thought I would need to change. Below reflects the whole code, with the changes you recommedned. I am getting a debugging error when I try to use it. Thoughts?

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: VBA Macro that converts and saves the worksheet into a PDF & customizing the file

    I think I might have figured out why I am getting a debugging error. The folder for that particular period of time is labeled "070111 - 071411", but the data in "B9" is "07/01/11 - 07/14/11". Since a folder cannot contain "/ or \", it is not finding the correct path. I wonder if there is a way for the code to take the dates with slashes, and convert it into a date without so that it can find the correct path and save the PDF?

  5. #5
    Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: VBA Macro that converts and saves the worksheet into a PDF & customizing the file

    Okay, I have updated the information in B9 to reflect the date range without slashes. It might also have helped if I had named the folder with the correct year. doh! But, all is well and the macro is working properly.
    Last edited by jonvanwyk; 12-29-2011 at 09:54 AM.

+ 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