Docx zu PDF
13.04.2018 14:16:44
Cord
Ich bin neu hier im Forum genau wie in der Programmierung mit VBA.
Ich versuche ein Modul anzupassen, das ein ehemaliger Kollege geschrieben hat.
Er hat nach dem umwandeln alle PDF in einen Ordner im Hauptverzeichnis gespeichert.
Ich möchte jetzt die PDF in die jeweiligen Unterverzeichnisse legen und die .docx löschen.
Diese beiden Sachen wären die ersten Schritte letzter Schritt wäre eine vorhandene .PPTX mit einem Schreibschutz zu versehen.
Nachdem ich die Umwandlungszeile mehrfach angepasst habe bin ich leider nicht weitergekommen. Entweder kommt garnichts oder Fehlermeldungen.
Vielleicht hat ja hier jemand eine einfache Lösung für mich mit Erklärung warum das so geht.
Private Sub CreatePdfWalkFolders(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 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