Hi,
I am trying to change the destination of this command. Typically every Windows user on Windows 7 or later has the filepath C:\User\{username}\Desktop Folder. And this is where i want the file to export the PDF to.
Here is my code
Option Explicit
Sub SaveSheetsAsPDF()
Dim wksAllSheets As Variant
Dim wksSheet1 As Worksheet
Dim strFilename As String, strFilepath As String
'Set references up-front
Set wksSheet1 = ThisWorkbook.Sheets("Helvar Snags")
wksAllSheets = Array("Helvar Snags", "Yes", "No")
strFilepath = "C:\Helvar Snags\"
'Create the full Filename using cells D6, E6 and F6
With wksSheet1
'Assemble the string cell-by-cell, "D6 E6-F6"
strFilename = strFilepath & .Range("D11").Value & " " & _
.Range("C1").Value & "-" & _
.Range("F31").Value & ".pdf"
End With
'Save the Array of worksheets (which will be selected) as a PDF
ThisWorkbook.Sheets(wksAllSheets).Select
wksSheet1.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strFilename, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
'Make sure all the worksheets are NOT left selected
wksSheet1.Select
End Sub
Currently my save file path is "C:\Helvar Snags\" a folder of which the engineer or project engineer would need to create themselves or it simply will not output. By using the desktop folder, the sheet will always output. I have alleviated the issue of having the same file name as the strFilepath Ranges D11,C1,F31 are "project names, dates and times" which constantly change as i have converted the date and the time to a numerical.
Any and all help would be greatly appreciated, proper headscratcher this.
The link of the template is below
Link: https://www.dropbox.com/s/cbtpv9sxv1...heet.xlsm?dl=0
The module to look at is Module 18.
Cheers All
Bookmarks