General Computing
pdf microsoft-office conversion autohotkey context-menu
Updated Sat, 02 Jul 2022 13:29:15 GMT

Add Right-Click Save as PDF in Windows Explorer


I'm looking for a way to be able to add some options to the Right Click Context menu in Windows 7. I really don't have much experience in programming much but I am very eager and willing to learn.

Specifically I'd like to be able to Right Click a word document and have it convert or save as a .PDF file. I want to be able to convert existing documents into PDF format. The documents are 99% of the time going to be Microsoft Word documents so if there is a way to automate that, guidance there is appreciated.

I'm aware there are other methods of doing this such as downloading a "PDF Printer" but I would rather avoid that method if I could. I would also like to avoid downloading more software to install on user's PC's if possible as well.

Hopefully I am not being very demanding but I really do appreciate any help or guidance you can offer.

(As a Bonus I'd like to see if I can also get the option to Saves as PDF and Send as an attachment if possible.)




Solution

I apologize for forgetting about this question but at least I am finally answering the question, right?

I could not find a way to accomplish this the way I wanted so I did a slight workaround. I created and compiled 2 separate .ahk (AutoHotkey) scripts and added them to the right click context menus.

Here are the scripts:

Convert .DOC and .DOCX to PDF (Requires Office 2007 or 2010)

; AutoHotkey Script by Cyborg v1.5
; This script is designed to be compiled and ran in the user's Send To Right-Click Menu.
; The user needs to right click a word document go into the send to menu and choose this
; script. After launching the script the selected file will open in its version of Word
; and open the menus to save it as a PDF. In this version the user is unable to rename the
; the file.
; NOTE: In order for this to work correctly with Office 2007 you MUST have already installed
; the PDF/XPS converter from Microsoft.
SetTitleMatchMode 2
Loop %0%
{
Path := %A_Index%
Run,% Path
}
IfWinExist, Microsoft Word
    WinActivate
sleep 1000
Word2007:
IfExist, C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE ; Microsoft Word 2007
{
    Send ^s
    Send !f
    Send f
    Send p
    Sleep 500
    Send {Enter}
    Sleep 500
    WinClose, Microsoft Word
}
else
{
    Goto, Word2010
}
return
Word2010:
IfExist, C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE ; Microsoft Word 2010
{
    Send ^s
    Send !f
    Send d
    Send p
    Send a
    Sleep 500
    Send {Enter}
    Sleep 500
    WinClose, Microsoft Word
}
else
{
    Goto, Word2013
}
return

Convert .XLS and .XLSX to PDF (Requires Office 2007 or 2010)

; AutoHotkey Script by Cyborg v1.5
; This script is designed to be compiled and ran in the user's Send To Right-Click Menu.
; The user needs to right click a word document go into the send to menu and choose this
; script. After launching the script the selected file will open in its version of Excel
; and open the menus to save it as a PDF. In this version the user is unable to rename the
; the file.
; NOTE: In order for this to work correctly with Office 2007 you MUST have already installed
; the PDF/XPS converter from Microsoft.
SetTitleMatchMode 2
Loop %0%
{
Path := %A_Index%
Run,% Path
}
IfWinExist, Microsoft Excel
    WinActivate
sleep 1500
Excel2007:
IfExist, C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE ; Microsoft Excel 2007
{
    Send ^s
    Send !f
    Send f
    Send p
    Sleep 700
    Send {Enter}
    Sleep 700
    WinClose, Microsoft Excel
}
else
{
    Goto, Excel2010
}
return
Excel2010:
IfExist, C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE ; Microsoft Excel 2010
{
    Send ^s
    Send !f
    Send d
    Send p
    Send a
    Sleep 500
    Send {Enter}
    Sleep 500
    WinClose, Microsoft Excel
}
else
{
    Goto, Excel2013
}
return
Excel2013:
    MsgBox, Excel 2013 Not Configured for this Script.
return

Once I wrote these scripts and compiled them into .exes I placed them into the SendTo by following this guide by HowToGeek.

You may also be able to apply each script to each filetype but I didn't look into that.