Auto save files daily in pdf that has pi values

kipras_b

New Member
Joined
Jun 28, 2013
Messages
7
Hello,

This is my first time here so forgive me if there is already a thread on this. Now I am just ok with excel I know this and that but not a pro on it so I need help.

Here is what I got:

I created a report that records PI values of motors and DPs on different equipment daily and updates them automatically. Now I have to open that file each day and save it as daily as a pdf. I was wondering if there is a code that I can make that Excel would save that file for that day for example today it would save in the folder as " 06282013" as a pdf with out me going in there and saving it myself. So by the end of the week I could just open my folder and find 5 pdf files saved in the daily folder. Also, can I seperate the save files such that it would save in different month folder for example it would save each day in June but when July comes it would start saving in July folder? If its possible could you guide me to do the right code, I'm assuming this has to be done in Visual Basic but might be wrong. Thanks for your help again!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I don't have Excel 2007+ to save as PDF, so can't give you the complete code. Record a macro of you saving the workbook as a PDF then use the file name produced by the following code instead of the hard-coded file name generated by the macro recorder.

Code:
Sub Save_Daily_PDF()

    Dim monthFolder As String
    Dim fileName As String
    
    monthFolder = "C:\Path\To\Main\Folder\" & Format(Date, "mmmm") & "\"         'CHANGE MAIN FOLDER PATH
    If Dir(monthFolder, vbDirectory) = "" Then MkDir monthFolder
    fileName = monthFolder & Format(Date, "mmddyyyy") & ".pdf"
    
    MsgBox fileName
    
End Sub
Change the main folder path where indicated.
 
Upvote 0
Thank you it worked I added this to the code and it started saving in .pdf format

Code:
    ActiveWorkbook.ExportAsFixedFormat xlTypePDF, fileName, xlQualityStandard, , , , , True

Now do I have to run excel and then run the macro everytime I save this file or is it possible to modify the code that it would save this everyday without me running the code manually or even opening exel?
 
Upvote 0
To be more precise I would like to know if it is possible to open a macro at specific time when the excel is not opened? Or does the excel have to be always opened for it to save?
 
Upvote 0
Yes, it is possible. Create a VBScript (.vbs) file which opens the workbook and runs Save_Daily_PDF. Use Windows Task Scheduler to run this .vbs file when required. There should be examples of this technique if you search.
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,698
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top