Nun der Code
msgbox 1 leeres Vorlage wird erstellt
msgbox 2 bmp Datei wird geladen
msgbox 3a Export als PDF und speichern als pdfDatei
msgbox 4 speichern der temporären wordDatei
msgbox 4a schließen, beenden von Word.
' Word-Objekt erzeugen
Dim wApp As Word.Application
Set wApp = CreateObject("word.Application")
With wApp
' Word nicht anzeigen
.Application.Visible = True
MsgBox "1"
Form400.List1.AddItem "App geladen"
Form400.PB1.Value = 40
' Word-Dokument laden und export
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
' Documents.Add Template:="C:\VIM}VIMScann\OLD\1DA.docx",
' NewTemplate:=False, DocumentType:=0
MsgBox "1a"
GoSub SeiteEinrichten
Form400.List1.AddItem "Seiten einrichten"""
Form400.PB1.Value = 50
MsgBox "2"
SeitenZahl = UBound(bmpD, 1)
For i = 0 To SeitenZahl
Select Case i
Case 0
MsgBox "2a"
Form400.List1.AddItem "2a " & bmpD(i)
Selection.InlineShapes.AddPicture FileName:=bmpD(i), _
LinkToFile:=False, SaveWithDocument:=True
Case Is > 0
MsgBox "2b"
' For k = 0 To SeitenZahl
Form400.List1.AddItem "2b " & bmpD(i)
Selection.InsertNewPage
Selection.InlineShapes.AddPicture FileName:=bmpD(i), _
LinkToFile:=False, SaveWithDocument:=True
' Next k
End Select
Next i
MsgBox "3"
'Speichern, wird am Ende wieder gelöscht.
'Damit wird die Abfrage Speichern unter unterdrückt
' ActiveDocument.SaveAs2 "D:\VIM\VIMScann\1DA.docx"
MsgBox "3a"
'Export nach pdf
Form400.List1.AddItem "Speichern " & pdfObjFileName
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
pdfObjFileName, ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
True, UseISO19005_1:=True
Form400.List1.AddItem "Nach pdf umgewandelt"
Form400.PB1.Value = 60
' nach getaner Arbeit, Word wieder beenden
MsgBox "4"
' ChangeFileOpenDirectory "D:\VIM\VIMScann\"
ActiveDocument.SaveAs2 FileName:="1DA.docx", FileFormat:= _
wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False, CompatibilityMode:=15
MsgBox "4a"
ActiveDocument.Close
Application.Quit
Set wApp = Nothing
MsgBox "4b"
' Fso.DeleteFile "D:\VIM\VIMScann\1DA.docx", True
MsgBox "5"
Set Fso = Nothing
Form400.List1.AddItem "Konvertierung beendet"""
Form400.PB1.Value = 70
MsgBox "6"
End With
Exit Sub
SeiteEinrichten:
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(0)
.BottomMargin = CentimetersToPoints(0)
.LeftMargin = CentimetersToPoints(0)
.RightMargin = CentimetersToPoints(0)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.25)
.FooterDistance = CentimetersToPoints(1.25)
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
Return |