Hi - I came to this forum a while ago and I got some great advice on the code below.. worked perfectly for the intended use however I am now trying to expand on it a little.
When a user clicks the Command button (Save) the below code runs and saves the worksheet as intedned however, I am trying to work out how to open a hyperlink once saved.. the idea is that once the worksheet has been saved, the user is automatically directed to a Microsoft forms page to upload the saved document.
Hope that makes sense. Thanks in advance
When a user clicks the Command button (Save) the below code runs and saves the worksheet as intedned however, I am trying to work out how to open a hyperlink once saved.. the idea is that once the worksheet has been saved, the user is automatically directed to a Microsoft forms page to upload the saved document.
Hope that makes sense. Thanks in advance
VBA Code:
Sub PDFActiveSheet()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strTime As String
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
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"
strName = wsA.Range("I5").Value & " (" & wsA.Range("I19").Value & ")"
strFile = strName & ".pdf"
strPathFile = strPath & strFile
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile <> "False" Then
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "Template Saved"
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "Template could not be Saved"
Resume exitHandler
End Sub