cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Radhika1
Helper IV
Helper IV

How to convert word doc to pdf in PAD

Hi,

 

Is there any option available in PAD to automatically convert word doc to pdf? Please help

1 ACCEPTED SOLUTION

Accepted Solutions
yoko2020
Resolver II
Resolver II

If you have microsoft office installed, you can use powershell

 

#Creates a Word-Object
$word = New-Object -ComObject Word.Application
$word.Visible = $false
$doc = $word.Documents.Open("C:\Temp\Document.docx")
#Creates the PDF file
$name = ($doc.FullName).replace('docx', 'pdf')
$doc.SaveAs($name, 17)
$doc.Close()
$word.Quit()

View solution in original post

9 REPLIES 9
yasunm02
Solution Sage
Solution Sage

Hi @Radhika1 

Unfortunately PAD doesn't have Word automation actions right now. You have to automate it by UI elements.

Try this sequence:

1. 'Run application' and provide the fulle name of .doc file to open it

2. 'Get window', foreground window (%AutomationWindow% as output)

3. 'Focus window', by instance= %AutomationWindow%

4. 'Send keys' {LControlKey}({P}) 'This will open Print option in Word

5.  'Set drop-down list value in window': here you have to capture the Printer drop-down field UI. Operation= Select option(s) by name, Name= 'Microsoft Print to PDF'

6. 'Press button in window': capture the Print button UI

7. From here, you have to select folder + name of saved file. You can use Message Box actions to input folder/name you want, or predefine it in a variable..

 

Good luck!

yoko2020
Resolver II
Resolver II

If you have microsoft office installed, you can use powershell

 

#Creates a Word-Object
$word = New-Object -ComObject Word.Application
$word.Visible = $false
$doc = $word.Documents.Open("C:\Temp\Document.docx")
#Creates the PDF file
$name = ($doc.FullName).replace('docx', 'pdf')
$doc.SaveAs($name, 17)
$doc.Close()
$word.Quit()

View solution in original post

I tried this using PowerShell, it is working but can you explain me the code like how it works because I am not aware of powershell script.

If you can give me an explanation of the code, I can understand the code better and incase any changes needed, I can modify.

Hi

Is there a powershell code for png files to PDF?

Thanks

@Radhika1 

This is the code for running in PAD.

#Get word file location from PAD variable
$PathFile = '%PathFileFromPAD%'

#Creates a Word-Object
$word = New-Object -ComObject Word.Application

#Set word instance hidden
$word.Visible = $false

#Open the document
$doc = $word.Documents.Open('$PathFile')

#Creates the PDF file
$name = ($doc.FullName).replace('docx', 'pdf')

# 17 is pdf format https://docs.microsoft.com/en-us/office/vba/api/word.wdsaveformat
$doc.SaveAs($name, 17)

#Close instance
$doc.Close()
$word.Quit()

 

 

thanks!

Pavel_NaNoi
Resolver II
Resolver II

Funnily enough there is an action that can convert a word document into a pdf called "Rename File(s)" where you can change the extension, unfortunately its bugged, it does the job but the pdf file it makes is un-openable.

yes, I tried "Rename File(s)" before and as you said, it is not working as expected.

I have a folders which have multiple file extensions that have to be converted to pdf. For ex: I have .doc, .docx, .jpg.

Is there a single power shell code to convert these file extensions  to pdf?

Please help.

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (1,935)