Skip to content

Commit 57b67c6

Browse files
authored
Add files via upload
1 parent b5d6d78 commit 57b67c6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Scripts/Export-PDF-To-Docx.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Add-Type -AssemblyName System.Windows.Forms
2+
3+
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
4+
$openFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
5+
$OpenFileDialog.Multiselect = $false
6+
7+
if ($OpenFileDialog.ShowDialog() -eq 'OK') {
8+
$pdfPath = $OpenFileDialog.FileName
9+
Write-Host "File selected: $pdfPath" -ForegroundColor Green
10+
Write-Host " "
11+
12+
$wordPath = [System.IO.Path]::ChangeExtension($pdfPath, ".docx")
13+
Write-Host "Ruta del PDF: $wordPath" -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+
Write-Host "Exporting $pdfPath to $wordPath" -ForegroundColor Yellow
23+
Write-Host " "
24+
$txt = $wordObject.Documents.Open(
25+
$pdfPath,
26+
$false,
27+
$false,
28+
$false)
29+
$wordObject.Documents[1].SaveAs($wordPath)
30+
$wordObject.Documents[1].Close()
31+
$wordObject.Quit()
32+
Write-Host "Exporting completed!" -ForegroundColor Green

0 commit comments

Comments
 (0)