Save as other formats in Word 2007

M

Mark Dullingham

Office 2007

I have added the 'save as other formats' button to my quick access toolbar
but is it possible to change the default format for this button to a
different format than the normal save button ie PDF

I poduve a lot of docs in word but then nedd to save them in the same
directory as PDF's. Icurrently us 'Save As' then choose PDF.

If I can change the default format for just the 'save as other formats' it
will make things a bit simpler.

Thanks in advance
 
J

Jay Freedman

Mark said:
Office 2007

I have added the 'save as other formats' button to my quick access
toolbar but is it possible to change the default format for this
button to a different format than the normal save button ie PDF

I poduve a lot of docs in word but then nedd to save them in the same
directory as PDF's. Icurrently us 'Save As' then choose PDF.

If I can change the default format for just the 'save as other
formats' it will make things a bit simpler.

Thanks in advance

You can't change the behavior of the "Save as other formats" button. You
could write a macro that would display the Save As dialog with a different
file type. But if you want the PDF to have the same base filename with the
..pdf extension, you might as well just have the macro do the save without
showing the dialog.

Put this macro into your Normal.dotm template (see
http://www.gmayor.com/installing_macro.htm if needed):

Sub SaveAsPDF()
Dim fn As String
Dim fnpath As String

fn = ActiveDocument.Name
fnpath = WordBasic.FileNameInfo(fn, 5)
fn = fnpath & _
WordBasic.FileNameInfo(fn, 4) & ".pdf"

ActiveDocument.SaveAs _
FileName:=fn, _
FileFormat:=wdFormatPDF
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
M

Mark Dullingham

Jay,

That works great except it always sves in 'My Documents' not in the folder
the original document was opened from .

My knowledge of VBA is limited and although I can see were the file path is
derived from I don't know how to modify it.

Also (this is a minor thing) is it posible toloose the '.docx' estionsion
from the pdf file name. Is this something to do with -

fn = fnpath & _
WordBasic.FileNameInfo(fn, 4) & ".pdf"
part of the code.

Many thanks in advance
 
J

Jay Freedman

Hi Mark,

I haven't been able to reproduce either of the situations you
described.

The WordBasic.FileNameInfo function is one of several functions that
were never fully converted from the old WordBasic language to VBA.
There's a description of it at
http://www.word.mvps.org/FAQs/MacrosVBA/WordBasicCommands.htm.

The numeric argument tells the function what part of the file name or
path to return. The 5 says to return the path without the filename,
and the 4 says to return the filename without the extension. In my
tests these behave as advertised, even with paths on Windows 7 and
with .docx extensions. As an example, if I open the document
C:\temp\greek\Greek.docx and run the macro, it creates
C:\temp\greek\Greek.pdf.

As a troubleshooting procedure, open the Locals window in the VBA
editor and run the macro one statement at a time by pressing F8. Watch
the values of fnpath and fn in the Locals as the macro executes. What
happens at each step?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top