Programierung
16.01.2021 18:44:34
Johannes
Guten Abend
habe eine Excel Datei und ich möchte gerne mit diesen VBA Code auch noch zugleich in PDF speichern.
bitte um Hilfestellung
https://www.herber.de/bbs/user/143057.xlsm
Private Sub CommandButton2_Click()
Dim objFileDialog As FileDialog
Dim strPath As String, strName As String
strName = Range("B9").Text
Set objFileDialog = Application.FileDialog(fileDialogType:=msoFileDialogSaveAs)
With objFileDialog
.FilterIndex = 1
.InitialFileName = "\\Ls-wxl8ad\wmv\Rechnungen\2021\" & strName
If .Show Then strPath = .SelectedItems(1)
End With
Set objFileDialog = Nothing
If strPath vbNullString Then
Copy
ActiveSheet.Name = strName
Application.DisplayAlerts = False
Call ActiveWorkbook.SaveAs(Filename:=strPath, FileFormat:=xlOpenXMLWorkbook)
Application.DisplayAlerts = True
Call ActiveWorkbook.Close
End If
End Sub
Anzeige