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 - 02 Feb 2007 11:49 GMT
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
> I am modifying my Word AddIn to work with Word 2007. My AddIn
> intercepts the Word "save as..." by implementing a FileSaveAs macro.
[quoted text clipped - 29 lines]
>
> Dave
Patrick Schmid [MVP] - 02 Feb 2007 16:10 GMT
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
> Oh Dear,
>
[quoted text clipped - 37 lines]
> >
> > Dave
roadz - 05 Feb 2007 13:25 GMT
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] - 05 Feb 2007 16:38 GMT
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
> Patrick,
>
[quoted text clipped - 36 lines]
>
> Dave
Chepino - 23 Feb 2007 19:47 GMT
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??