1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| 'Variable
NomFICHIERPDF="nomfichierpdf"
'constantes
Const wdExportFormatPDF = 17
Const wdExportOptimizeForPrint = 0
Const wdExportAllDocument = 0
Const wdExportDocumentContent = 0
Const wdExportCreateNoBookmarks = 0
Path = Left(WScript.ScriptFullName, InStr(WScript.ScriptFullName, WScript.ScriptName)-1)
Const wdGoToBookmark = -1
Const wdDoNotSaveChanges = 0
Const ForReading = 1, ForWriting = 2
Const bWaitOnReturn = true
Dim WshShell, wordApp, wordDoc, wordRange, fso, f
Set wordApp = CreateObject("Word.Application")
wordApp.Visible = False
Set wordDoc = wordApp.Documents.Open(path & "Vide.doc")
'enregistrement
wordDoc.SaveAs(path & "test.doc")
'sauvegarde en pdf
strDocPDF = path & NomFICHIERPDF & ".pdf"
wordDoc.ExportAsFixedFormat strDocPDF, wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportAllDocument, 1, 1, wdExportDocumentContent, True, True, wdExportCreateNoBookmarks, True, True, False
wordApp.Quit
'fermer processus word
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'winword.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
'fenetre ok
wscript.echo "Enregistrement fichier :" & CHR(10) & " " & CHR(10) & path & NomFICHIERPDF & ".pdf"
'suppression fichier.txt
fso.DeleteFile(path & "test.doc") |
Partager