Kan ik in onderstaande VBA code daar waar C:\Facturen\ staat een verwijzing naar een cel gebruiken, bijv cel I10.
Zo ja, hoe komt de VBA code er dan uit te zien?
Zo ja, hoe komt de VBA code er dan uit te zien?
Code:
Sub PDFmetcelnaam()
Dim FacName As String
FacName = ActiveSheet.Range("C13").Value ' De macro haalt met dit command het factuurnummer op in de factuur, om deze later als naam voor het PDF-bestand te gebruiken.
If Dir("[COLOR="#FF0000"]C:\Facturen\[/COLOR]" & FacName & ".pdf") <> "" Then
MsgBox "Het bestand: " & FacName & ".pdf bestaat reeds" ' Een controle om geen dubbel PDF-bestand te maken.
' De map waarin je de PDF-bestanden in wilt creëeren moet op voorhand aangemaakt zijn!!
Exit Sub 'Verlaat de routine als het PDF-bestand reeds bestaat.
Else
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="[COLOR="#FF0000"]C:\Facturen\[/COLOR]" & FacName & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=True
End If
'confirmation message with file info
MsgBox "Het PDF bestand is opgeslagen in de map [COLOR="#FF0000"]C:\Facturen\ [/COLOR] " _
& vbCrLf _
& strPathFile
End Sub