1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Save PDF to a year directory each new year or month

Discussion in 'Business Applications' started by spooky1, Jul 2, 2012.

Thread Status:
Not open for further replies.
  1. spooky1

    spooky1 Thread Starter

    Joined:
    Jan 29, 2010
    Messages:
    126
    I have created
    C:\00 - savehere \2012
    C:\00 - savehere \2013
    C:\00 - savehere \2014

    current vba code is:-
    ChDir "C:\00 - savehere \2012"
    Range("c57:h102").ExportAsFixedFormat Type:=xlTypePDF, Filename:=composedfn & ".pdf"


    Is there a way to save to ChDir "C:\00 - savehere \ currentyear
    without having to change the vba integer value to each new year? or using if statements for each year? So when the 1st of jan comes it automatically save to the new current year directory and if possible creates a directory at the start of each new year as well?
     
  2. draceplace

    draceplace

    Joined:
    Jun 8, 2001
    Messages:
    2,583
    If folder exist....

    ' Does this directory exist? If not, create it.
    If objFSO.FolderExists(strParentPath) = False Then
    Set newFolder = objFSO.CreateFolder(strParentPath)
    Wscript.Echo "Put a ocr fold here" &
    Else
    'Save it here code'
    End If

    This will get you the year
    CurrentDate = Date
    File_Year = DatePart("yyyy",CurrentDate)

    You should be able to code it with this info
     
  3. spooky1

    spooky1 Thread Starter

    Joined:
    Jan 29, 2010
    Messages:
    126
    Thanks Draceplace
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1059389

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice