Ich habe Probleme mit diesem Code. Ziel dieses Codes ist es, alle Visio-Datei in Ordner von EXCEL VBA-Makro in PDF zu konvertieren ...Konvertieren von mehreren Visio-Datei in PDF durch Excel VBA
Mit diesem Code kann ich Visio-Datei öffnen, aber nicht in PDF-Datei konvertieren .... es "Objekt erforderlich" Fehler zeigt ....
FName = myPath & myFile
Dim objDoc: Set objeDoc = VisioApp.documents.Open(FName)
objDoc.ExportAsFixedFormat VisFixedFormatTypes = 1, FName, VisDocExIntent = 1, VisPrintOutRange = 0
ich bin vor Problem mit obigen Zeilen
Sub LoopAllExcelFilesInFolder()
Dim wb As Workbook
Dim myPath As String
Dim myFile As String
Dim myExtension As String
Dim FldrPicker As FileDialog
Dim FName As String
'Optimize Macro Speed
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'Retrieve Target Folder Path From User
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
myPath = .SelectedItems(1) & "\"
End With
'In Case of Cancel
NextCode:
myPath = myPath
If myPath = "" Then GoTo ResetSettings
'Target File Extension (must include wildcard "*")
myExtension = "*.vsd"
'Target Path with Ending Extention
myFile = Dir(myPath & myExtension)
'Loop through each Excel file in folder
Do While myFile <> ""
Set VisioApp = CreateObject("Visio.Application")
FName = myPath & myFile
Dim objDoc: Set objeDoc = VisioApp.documents.Open(FName)
'Application.ActiveDocument.ExportAsFixedFormat visFixedFormatPDF, "C:\Users\20098323\Desktop\BHAVIK\VAC-30001.pdf", visDocExIntentPrint, visPrintAll, 1, 53, False, True, True, True, False
objDoc.ExportAsFixedFormat VisFixedFormatTypes = 1, FName, VisDocExIntent = 1, VisPrintOutRange = 0
myFile = Dir
Loop
'Message Box when tasks are completed
MsgBox "Task Complete!"
ResetSettings:
'Reset Macro Optimization Settings
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Wenn Sie einen Verweis auf die Visio-Objektbibliothek hinzugefügt haben, dann ist VBA nicht jene visXxxxxx Konstanten erkennen. Wenn Sie Option Explicit verwendet haben, die Sie auf das Problem aufmerksam macht. –
Aber welche Art von Änderung sollte ich in diesem Code tun? –
Fügen Sie Option Explicit oben in Ihrem Codemodul hinzu. Das wird Sie darauf hinweisen, dass Sie Ihre Variable als "objeDoc" falsch geschrieben haben. Ich bin mir auch nicht sicher, was Sie mit diesen Parametern machen, aber das entspricht nicht meinen Vorschlägen. –