File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-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 = " 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
You can’t perform that action at this time.
0 commit comments