Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Override Word 2007 Save as

77 views
Skip to first unread message

roadz

unread,
Feb 2, 2007, 5:57:52 AM2/2/07
to
I am modifying my Word AddIn to work with Word 2007. My AddIn
intercepts the Word "save as..." by implementing a FileSaveAs macro.
This macro pops a VB form, and depending on how the user responds to
this form it sets the save path and executes the Word save as dialog.
In Word 2007 there are 6 different FileSaveAs* macros which I need to
override: FileSaveAsWord97_2003, FileSaveAsWordDocx,
FileSaveAsWordDotx, FileSaveAsOtherFormats, FileSaveAsPdfOrXps and
FileSaveAs. For each one I will need to set the appropriate file
extension and test that I have changed the dialog box behaviour. Here
is a simplified version of my current code:

Sub FileSaveAs()
Dim saveDialog As FileDialog
Dim path As String

path = GetPath 'Determine where to save the document

Set saveDialog = Dialogs(wdDialogFileSaveAs)
saveDialog.Name = path & ActiveDocument.Name
saveDialog.Display

End Sub


I am now going to have to write five more routines which set the
appropriate file extension on the saveDialog.Name property.

So finally, my question is... it there a better way to tackle this
problem? All I want to do is intercept the save as prompt and set the
path, then let Word carry on as normal.

All suggestions/comments gratefully received!

Dave

roadz

unread,
Feb 2, 2007, 6:49:52 AM2/2/07
to
Oh Dear,

It seems I can only intercept the FileSaveAsOtherFormats and
FileSaveAs commands! If I declare the other FileSaveAs* sub routines
in my .dot (or .dotm) they don't get fired!

Dave

Patrick Schmid [MVP]

unread,
Feb 2, 2007, 11:10:18 AM2/2/07
to
Use RibbonX and the command element there to repurpose those controls.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

"roadz" <david...@aimlegal.com> wrote in message
news:1170416992.6...@k78g2000cwa.googlegroups.com:

roadz

unread,
Feb 5, 2007, 8:25:43 AM2/5/07
to
Patrick,

Thanks for your comment.

I am slowly coming to the conclusion that I might as well rewrite my
AddIn for Word 2007 using Visual Studio Tools for Office. This way I
should end up with a much more neat and future proof solution (albeit
one that will only work in Office 2007).

If I am going for a rewrite then I think that a better solution to my
problem is to intercept the DocumentBeforeSave event and use the
ChangeFileOpenDirectory to set the path. However, I need to do a
similar thing with FileOpen so repurpopsing the FileOpen command seems
to be a good idea. I've created a new Word 2007 addin using VSTO 2005
SE and repurposed the command and it works perfectly! I can even slip
in my ChangeFileOpenDirectory command and let Word show the open
dialog itself!

For information, here is my RibbonX and my callback function.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="OnLoad">
<commands>
<command idMso="FileOpen" onAction="OnFileOpen"/>
</commands>
</customUI>

public void OnFileOpen(Office.IRibbonControl control, ref bool
CancelDefault)
{
string path = GetPath(); // Ask the user a question to
determine the path
if (path!="")
{
addin.Application.ChangeFileOpenDirectory(path);
}
CancelDefault = false; // Do NOT cancel the default behaviour
}

Dave


Patrick Schmid [MVP]

unread,
Feb 5, 2007, 11:38:47 AM2/5/07
to
Glad to see you have something working!
Ask again if you need any help.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

"roadz" <david...@aimlegal.com> wrote in message

news:1170681942.2...@h3g2000cwc.googlegroups.com:

Chepino

unread,
Feb 23, 2007, 2:47:22 PM2/23/07
to
hi, I got a trouble when i try to install an add-in. The problem is
that the component doesnt charge when I run the setup project, but
when i debug the code solution it works...

Can you tell me why??

0 new messages