473,588 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Word 2007 automation: problem with trapping save event

1 New Member
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 3734

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

Similar topics

1
12071
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 "word automation". I have foud a lot of exemple to use it but I need your precious help to
2
2617
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 course) which will merge the contents of files which I will point ie. 1.doc and 2.doc into one file: "12.doc" I've just tried to find smth in MSDN help, and in google archive of programing groups but still I don't know how to do it:(
4
11125
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 done this? Does it seem possible? I followed the instructions from a sample on the Microsoft knowledge base but it only seems to work when creating a VB.NET Windows .EXE, not an VB.NET ASP app.
3
6113
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 done this? Does it seem possible? I followed the instructions from a sample on the Microsoft knowledge base but it only seems to work when creating a VB.NET Windows .EXE, not an VB.NET ASP app.
12
3442
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. The problem I'm having is that I can't delete the word file I saved at the end of the process due to the file being locked by the email process. It appears to take longer than the code takes to complete due to virus checking software that...
2
6578
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
4744
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": strClassName = "XLMain" Case "Outlook": strClassName = "MSOutlook" Case "Word": strClassName = "OpusApp" Case Else: strClassName = "" End Select
10
3273
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 document in pdf and that is all I want done with it. How can I tell it to close the file without prompting me for anything? For Each row As DataRow In myDt.Rows Dim objWord As Application Dim objDoc As Document objWord =...
3
3236
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 display the document in a way that allows the user to view the document, but prohibits the document from being changed. I used HyperLink to attempt this, but the Word application is automatically launched, and the user can alter the document....
0
7929
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8228
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6634
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5729
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1459
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1196
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.