Ich habe hier mal einen Teil der Codestruktur angefügt und ich bin der Meinung dort viel Beispiele für late Binding zu finden, sollte ich hier falsch liegen bitte ich um Berichtigung.
Den Entwickler kann ich nicht mehr fragen ist nicht mehr greifbar leider.
Wobei das hier nur ein Teil des Codes ist sprich ein Modul.
Ich verstehe nicht, warum das im 2013 geht und 2016 nicht es sind alle Programme installiert und er durchsucht eine Ordnerstrucktur nach Dateien bestimmten Typs M.docx, PPT.pptx, LS.docx usw, wandelt diese in dem Modul in PDF um
und speichert sie in einem Ordner.
Wenn also das VBA sich nicht groß geändert hat sollte das doch gehen.
Option Explicit
Private pPdfPath As String
Public Sub CreatePdfMakro(control As IRibbonControl)
CreatePdf
End Sub
Public Sub CreatePdfShowResult()
CreatePdf
If pResultText <> "" Then
MsgBox pResultText, pResultIcon + vbOKOnly, "Syllabus Prüfer - " & ActiveWorkbook.Name
End If
End Sub
Public Sub CreatePdf()
Dim fileExcel As File
On Error GoTo MsgBoxFehler
pResultText = ""
pResultIcon = vbInformation
If Not IsSyllabusWorkbook() Then
pResultText = "Diese Excel Mappe ist keine Courseware Liste!" & vbCrLf & vbCrLf & "Bitte verwenden Sie die Korrekte Vorlage" & vbCrLf & "zum Erstellen einer Courseware Liste."
pResultIcon = vbCritical
Exit Sub
End If
If Not TestWorkbookExists() Then
pResultText = "Die Excel Mappe wurde noch nicht gespeichert!" & vbCrLf & vbCrLf & "Bitte speichen Sie die Mappe mit dem korrekten Namen" & vbCrLf & "in der Hierarchie des Kurses."
pResultIcon = vbCritical
Exit Sub
End If
TestOpenDocuments
Application.Cursor = xlDefault ' xlWait
Application.StatusBar = "PDF Erstellung beginnt."
Set fileExcel = fso.GetFile(ActiveWorkbook.FullName)
Set rootFolder = fileExcel.ParentFolder
pPdfPath = fso.BuildPath(rootFolder.path, "_PDF")
If Not fso.FolderExists(pPdfPath) Then
fso.CreateFolder pPdfPath
End If
Set appWord = CreateObject("Word.Application")
CreatePdfWalkFolders rootFolder
appWord.Quit
Set appWord = Nothing
GoTo noerr
MsgBoxFehler:
pResultText = "Fehler Nr. " & Err.Number & " von " & Err.Source & vbCrLf & Err.Description
pResultIcon = vbCritical
noerr:
Application.Cursor = xlDefault
Application.StatusBar = "PDF Erstellung beendet."
End Sub
Private Sub CreatePdfWalkFolders(ByVal fld As Folder)
Dim sfld As Folder, ch As Integer
Dim docs As files, sdoc As File, pdfdoc As File
Dim dinf As cDocumentInfo, dtyp As itsCwType
Dim pdfpath As String, wassaved As Boolean
Dim fidate As Date, pdfdate As Date
Set docs = fld.files
Set dinf = New cDocumentInfo
For Each sdoc In docs
dinf.FromFileName sdoc.Name
dtyp = dinf.TypeEnum
If dtyp = itsCwTypeManual Or dtyp = itsCwTypeLessonSummary Or _
dtyp = itsCwTypeWorksheetTask Or dtyp = itsCwTypeWorksheetSolution Then
dinf.Extension = ".pdf"
fidate = sdoc.DateLastModified
pdfpath = fso.BuildPath(pPdfPath, dinf.ToFileName)
If fso.FileExists(pdfpath) Then
Set pdfdoc = fso.GetFile(pdfpath)
pdfdate = pdfdoc.DateLastModified
Else
pdfdate = DateSerial(1900, 1, 1)
End If
If fidate > pdfdate Then
Application.StatusBar = "PDF Erstellung für " & sdoc.Name
Set docWord = appWord.Documents.Open(Filename:=sdoc.path, ReadOnly:=True, Visible:=True)
docWord.ExportAsFixedFormat OutputFileName:=pdfpath, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, _
OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, _
CreateBookmarks:=wdExportCreateHeadingBookmarks
docWord.Saved = True
docWord.Close
Set docWord = Nothing
End If
End If
DoEvents
Next sdoc
If fld.subfolders.Count > 0 Then
For Each sfld In fld.subfolders
ch = Asc(Left(sfld.Name, 1))
If ch > 47 And ch < 58 Then
DoEvents
CreatePdfWalkFolders sfld
End If
Next
End If
End Sub