File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments