Hi. Not a pro coder but this is what I have so far.
Sub SaveasPDF()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler
Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
Sheets(Array("total", wsA.Name)).Select
'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & ""
strName = "WORK AS OF" & " " & Format(Date, "MM-DD-YYYY")
'create default name for saving file
strFile = strName & ".pdf"
strPathFile = strPath & strFile
'Create DAily folder under Today's dte
MkDir ("P:\INFORMATION TECHNOLOGY\Non-Public\Applications" & Format(Date, "MM-DD-YYYY"))
'export to PDF in current folder
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strPathFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'confirmation message with file info
MsgBox "PDF file has been created: " _
& vbCrLf _
& strPathFile
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
End Sub
I want to move the converted pdf to be saved in the folder that I'm creating under today's date. Currently it is being saved in the directory that the excel is in. There will just be one pdf labeled 'WORK AS OF MM-DD-YYYY' format which I want to move.
For example, if you run the code, the WORK AS OF 06-25-2019 should move to the 06-25-2019 folder that I'm creating.
Please help.
Sub SaveasPDF()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler
Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
Sheets(Array("total", wsA.Name)).Select
'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & ""
strName = "WORK AS OF" & " " & Format(Date, "MM-DD-YYYY")
'create default name for saving file
strFile = strName & ".pdf"
strPathFile = strPath & strFile
'Create DAily folder under Today's dte
MkDir ("P:\INFORMATION TECHNOLOGY\Non-Public\Applications" & Format(Date, "MM-DD-YYYY"))
'export to PDF in current folder
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strPathFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'confirmation message with file info
MsgBox "PDF file has been created: " _
& vbCrLf _
& strPathFile
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
End Sub
I want to move the converted pdf to be saved in the folder that I'm creating under today's date. Currently it is being saved in the directory that the excel is in. There will just be one pdf labeled 'WORK AS OF MM-DD-YYYY' format which I want to move.
For example, if you run the code, the WORK AS OF 06-25-2019 should move to the 06-25-2019 folder that I'm creating.
Please help.