Office program

  • Thread starter Thread starter Alan T
  • Start date Start date
A

Alan T

I would like to start a MS Word program to open a specified document, that's
fine by calling Process.Start().
However, I would like to offer the user only Save option to save the
document, ie no "Save As".

Any idea?
 
I would like to start a MS Word program to open a specified document,
that's fine by calling Process.Start().
However, I would like to offer the user only Save option to save the
document, ie no "Save As".

Any idea?

I'm not sure you can do this with Process.Start(), because all that does (in
your case) is take a document, examine its file extension, then open it with
whatever application is defined as the default application for that
extension. In Explorer, change the default application for .doc from Word to
Wordpad and you'll see what I mean.

Secondly, you need to do more than just force Windows to open a document
with its default application - you need to manipulate that application when
it starts.

To do this, you need to use Office Automation.

The following MSDN article shows you how to do this - it uses Excel, but the
principle is the same: http://support.microsoft.com/kb/302902/

Once you have your Word application object (e.g. objWord), do the following:

objWord.CommandBars("File").Controls(5).Enabled = False

Obviously, you should enhance this so that it actually checks that
Controls(5) on the File menu is actually the Save As menuitem etc...

You should also have a look at this, if you haven't already:
http://www.microsoft.com/downloads/...1E-3060-4F71-A6B4-01FEBA508E52&displaylang=en
 
Hi,

Can you tell me how do I get the Word to be opened with the specified file
name?

These are my code:

Type objClassType;

objClassType = Type.GetTypeFromProgID("Word.Application");

objApp_Late = Activator.CreateInstance(objClassType);

// how to specify the word document name ??

Parameters = new Object[1];

Parameters[0] = true;

objApp_Late.GetType().InvokeMember("Visible", BindingFlags.SetProperty,

null, objApp_Late, Parameters);

objApp_Late.GetType().InvokeMember("UserControl", BindingFlags.SetProperty,

null, objApp_Late, Parameters);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top