Skip to content

Commit e56a222

Browse files
authored
Add files via upload
1 parent f317907 commit e56a222

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Scripts/Export-Docx-To-PDF.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Add-Type -AssemblyName System.Windows.Forms
2+
3+
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
4+
$openFileDialog.Filter = "Word Files (*.docx)|*.docx";
5+
$OpenFileDialog.Multiselect = $false
6+
7+
if ($OpenFileDialog.ShowDialog() -eq 'OK') {
8+
$wordPath = $OpenFileDialog.FileName
9+
Write-Host "File selected: $wordPath" -ForegroundColor Green
10+
Write-Host " "
11+
12+
$pdfPath = [System.IO.Path]::ChangeExtension($wordPath, ".pdf")
13+
Write-Host "Ruta del PDF: $pdfPath" -ForegroundColor Green
14+
Write-Host " "
15+
} else {
16+
Write-Host "No file selected." -ForegroundColor Yellow
17+
Write-Host " "
18+
}
19+
20+
$wordObject =new-object -ComObject "Word.Application"
21+
$wordObject.Visible = $True
22+
23+
Write-Host "Exporting $wordPath to $pdfPath" -ForegroundColor Yellow
24+
Write-Host " "
25+
$wordFile = $wordObject.Documents.Open($wordPath)
26+
$wordFile.SaveAs([ref] $pdfPath, [ref] 17)
27+
$wordFile.Close()
28+
$wordObject.Quit()
29+
Write-Host "Exporting completed!" -ForegroundColor Green

0 commit comments

Comments
 (0)