Beste forumleden,
Ik ben op zoek naar een oplossing voor het opslaan van mijn bestand.
Onderstaande heb ik een code die voor mij goed werkt alleen de bestandsnaam klopt niet.
Als ik nu op de knop opslaan druk zet hij automatisch als naam de datum neer strTime = Format(Now(), "dd-mm-yyyy\_hh-mm")
Ik zou als voorstel voor de bestandsnaam graag een verwijzing naar een cel maken.
Hoe moet ik deze toevoegen aan onderstaande macro?
Alvast bedankt voor jullie reactie
Sub PDFActiveSheet()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strTime As String
Dim strName As Variant
strName = Range("L3").Value
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
strTime = Format(Now(), "dd-mm-yyyy\_hh-mm")
'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"
'create default name for savng file
strFile = strName & "_" & strTime & ".pdf"
strPathFile = strPath & strFile
'use can enter name and
' select folder for file
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Kies de juiste map en pas eventueel de bestandsnaam aan!")
'export to PDF if a folder was selected
If myFile <> False Then
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'confirmation message with file info
MsgBox "PDF file is opgeslagen!" _
& vbCrLf _
& myFile
Else
MsgBox "PDF file is niet opgeslagen"
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "PDF file is niet opgeslagen"
Resume exitHandler
End Sub