472,338 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,338 software developers and data experts.

Word 2007 automation: problem with trapping save event

1
I'm developing an addin for Word 2007 and I need to determine whether a user
saves a Word 2007 document in an older format (97-2003) after a save as is
done. The scenario is that the user starts out with a Word 2007 document,
saves that document to disk, then saves the same document in an older format

If the user saves a doc in an older format, I want to turn off certain
features of my add-in. I'm able to trap the save event easily enough and
provide the user with the Save as dialog and process the document type after
the save is completed. Here's a code snippet:

Expand|Select|Wrap|Line Numbers
  1. void _appClass_DocumentBeforeSave(Microsoft.Office.Interop.Word.Document 
  2. Doc, ref bool SaveAsUI, ref bool Cancel)
  3.         {
  4.  
  5.             if (SaveAsUI == true)
  6.             {
  7.                 string _origName = Doc.FullName;
  8.                 Cancel = true;
  9.                 object missing = Type.Missing;
  10.                 Word.Dialog fileSaveAsDlg = Application.Dialogs [Word.WdWordDialog.wdDialogFileSaveAs];
  11.                 fileSaveAsDlg.Show(ref missing);
  12.                 if (Doc.FullName != _origName)
  13.                 {
  14.                      ...do stuff
  15.                 }
  16.  
  17.              ... check document version type
  18.             }
  19.  
  20.         }
  21.  
  22.  
The problem is that Word 2007 supports save as dialogs for specific document
types but the only save as dialog I can produce above is a generic one that
defaults to the new file format. To produce a format-specific dialog, click
Word's Office button, then click Save As and you're presented with the option
of saving as a variety of document types.

If I take the approach above, I break this very helpful feature because even
though the user may have selecte to save as Word 97-2003 format, she still
gets the save as dialog defaulting to the Word 2007 format and has to
manually change it. However there is no way I've discovered to determine
which type of save as box the user intended and even if I could, I don't know
how to produce a save as dialog that matches the user's choice.

There also doesn't seem to be any post-save events so I can't process the
document type after the save event has completed. This seems to be a
deficiency in the Word 2007 object model.

Can anyone provide any guidance on a decent work-around for this? I want to
be able to fully support the Word 2007 functionality of being able to provide
the user with a document type-specific save as dialog while still being able
to trap the save event and process the document after the save (specifically
the save as) event has completed.

Thanks
Jan 7 '08 #1
0 3612

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mickeydisn | last post by:
Sub: C++ Word automation Extract text hello. I want extact text form a word document using a visual c++ programme. I have see a lot of...
2
by: Radek | last post by:
Hi, I have got such problem: in my directory "C:\folder" I have 3 files in MS WORD (having tables, images etc), these are: "1.doc", "2.doc",...
4
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created...
3
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that...
12
by: Steve | last post by:
I've been building an application that will merge fields in a text file with a word template, save the resulting word file out to the user's hard...
2
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Is it possible to convert a microsoft word document to pdf in .net code. If anyone has done this before, please let me know.
4
by: Bob Darlington | last post by:
I'm using the following code to check whether Word is running: Function IsAppRunning(strAppname As String) As Boolean Dim strClassName As String...
10
by: cj2 | last post by:
I open a word template in VB and add values to the bookmarks then save the document as as pdf. When I then go to close the document it pops up a...
3
by: Greg (codepug | last post by:
For the purpose of viewing a document that I would like to modify on rare occassion using word. I would like to create a document with MS Word,...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.