473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 3720

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 documentation. and my analysis is that I must use a...
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", "3.doc". I want to write an application (C# of...
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 document to an SQL Server database. Has anyone...
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 created document to an SQL Server database. Has anyone...
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 drive, and then email the file as an attachment. ...
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 Select Case LCase$(strAppname) Case "Excel": ...
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 save as dialog box. It's already saved the...
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, and then have my Access Application launch and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.