Export data Automatically

sahel

New Member
Joined
Mar 8, 2018
Messages
2
Hello
I have an Excel sheet connected with controller, its not close (24 H running) and updated every some times with new data,
i need to export all data as PDF or XPS automatically every day at 12:00 AM :confused::confused: without i close the original file or touch it:eeek:.
so could any one can help me or send me full macros to be add with excel-vb

Thanx
:)
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
This saves it to the desktop. You can change where it saves to as one of the comments in the code states. See other comments as well.

Just run the 'Schedule' subroutine.

Code:
Sub Schedule()
Application.OnTime "12:00 AM", "ExportToPDF", "12:05 AM", True
End Sub


Sub ExportToPDF()
Dim Path As String
Dim FileName As String
Dim ws As Worksheet


Set ws = ActiveSheet 'Can change to any sheet in workbook
FileName = ActiveWorkbook.Name 'Can change to any name you want the file to be called
Path = Environ("UserProfile") & "\Desktop\" & FileName 'Can change the location you want the PDF to be saved to


ws.ExportAsFixedFormat xlTypePDF, Path, xlQualityStandard


End Sub
 
Last edited:
Upvote 0
Hi lrobbo314

Thank you very much, i try this code its working fine
but still i have small problem that i need a PDF file name is Current date, i mean i no need to replace existing one.
Could you help me please
thanks
 
Upvote 0
Code:
Sub Schedule()
Application.OnTime "12:00 AM", "ExportToPDF", "12:05 AM", True
End Sub


Sub ExportToPDF()
Dim Path As String
Dim FileName As String
Dim ws As Worksheet


Set ws = ActiveSheet 'Can change to any sheet in workbook
FileName = Format(Now(),"MM.DD.YYYY")
Path = Environ("UserProfile") & "\Desktop\" & FileName 'Can change the location you want the PDF to be saved to


ws.ExportAsFixedFormat xlTypePDF, Path, xlQualityStandard


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,846
Messages
6,181,304
Members
453,031
Latest member
Chris_1

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