Save as JPEG

Get help with using AutoHotkey and its commands and hotkeys

Save as JPEG

05 Nov 2014, 23:35

I am trying to save publisher files as JPEGs and would like to create a one stroke shortcut to save as JPEG instead of pulling down the file, clicking save as, and then dropping down the menu of file types to select JPEG. What is the proper code to write for this?

Re: Save as JPEG

06 Nov 2014, 10:36

You could try ... ctItem.htm but that probably won't work. As it is MS application it might be able to record a VB Script Macro in Publisher itself to do it and assign a hotkey to it - if that won't work you could try simple send method:

Just write down the KEYSTROKES you need to type to save the file as JPG, for example

- Alt-f to open the file menu
- s to select the save as submenu
- alt-t to select the filetype
- Down X times to select JPG or just the J key 3 times
- Enter to save
- send a file name + Enter again

If that works, use the to send those keystrokes.
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Save as JPEG

06 Nov 2014, 15:28

Try this.
When the user presses F1 in Publisher, they will be prompted to enter a name of a file to SaveAs .jpg.

Code: Select all

; Constants (use these to specify which resolution to use in SaveAsPicture below)
pbPictureResolutionDefault = 0
pbPictureResolutionWeb_96dpi = 1
pbPictureResolutionDesktopPrint_150dpi = 2
pbPictureResolutionCommercialPrint_300dpi = 3
return      ; End of auto-execute section

#IfWinActive ahk_class MSWinPub
try     ; try to get an instance of the Publisher application object
    oPub := ComObjActive("Publisher.Application")
catch { ; if an instance of Publisher could not be found, do nothing  
    MsgBox, 0x10, Publisher not found!

; Prompt the user to enter a file name and path to SaveAs with
FileSelectFile, SavePath, S 16, %A_Desktop%, Enter a Name to save file as .jpg, (*.jpg)
if (ErrorLevel) ; If the user dismissed the dialog without selecting a file, return

; If the last four characters of the SavePath are not ".jpg", add the dot and extension
if (SubStr(SavePath, -3) != ".jpg")
    SavePath .= ".jpg"

oPub.ActiveDocument.Pages(1).SaveAsPicture(SavePath, pbPictureResolutionCommercialPrint_300dpi) 


Return to “Ask For Help”

Who is online

Users browsing this forum: blue83, jly, michalb93 and 43 guests