After opening a Word document, using .NET interop, a dialog box is created that blocks programmatic editing of the opened file. The user cannot see the winword.exe process and so cannot close the dialog. Is there a way to close a dialog or to prevent them being opened on startup?
I believe it might be the dialog asking first time users to set their name and initials.
Note: I know that it would be nicer to avoid using the interops and am familiar with Aspose products.
See my answer here.
Basically, you need to disable all "alerts", such the dialog that you describe above. Instead of "MSProject", use "Word" of course.
Related
I was loading an MS Word file programmatically using Interop.Microsoft.Office.Interop.Word.dll.
When the Word file is opened, I want to disable drag and drop facility for it.
How do I do that? Is it possible to achieve this in user32.dll?
You're probably looking for
Application.Options.AllowDragAndDrop = false;
Application.Options
Options class members
I'm not sure if any options you change persist or not when the application is closed, but I would make sure you revert any options changes you do when you application closes or in case of an unexpected termination.
I am debugging a C# program that calls Word 2007 for rendering of some office files. It all works well as long as Word starts up and shuts down properly.
In the few instances where it wasn't, there is a pop-up message from Word the next time. It basically says that it wasn't started properly last time and then asks if I would like to start it in Safe-mode. Is there any way of avoiding this popup message?
There are a few approaches here:
Do you really need to avoid safe mode, or just the dialog? If you can start Word with the /safe option then it will always be in safe mode and shouldn't ask you.
Do you know what causes safe mode? Maybe starting Word with the /a option to disable add-ins (assuming you're not using any) would prevent the cause of the crashing in the first place.
See if you can figure out what causes Word to think it should open in safe mode. There has to be a file or registry entry that trips it up. You can use Process Monitor to see what files and registry entries it looks at, and see which ones are different between traces from a regular startup and one where it asks for safe mode. Then make sure that condition doesn't exist just prior to opening Word.
See http://support.microsoft.com/kb/210565 for a list of command line options for Word.
I have the same problem with powerpoint. We run a theatre that does slide shows in between shows. If powerpoint somehow crashes or closes uncleanly, you are prompted to start in safe mode. What happens is that the "do you want to start powerpoint in safe mode" comes up and requires user intervention to fix. I would like to disable this "feature" or safe mode entirely. The closest I have come is the following fix, which I have now implemented but I do not know if it will actually prevent it or not until another crash (which can take months to happen - thankfully). Seems promising though!
Open up a blank Word document on your computer.
Click on the circular icon in the upper left-hand corner. Select "Word Options" from the menu.
Click on "Trust Center" on the left-hand side of the menu.
Select "Trust Center Settings."
Select the "Active X Settings" and uncheck the box for "Safe Mode." This will disable the feature in all Office programs.
Hit "OK" to save your changes and close the Microsoft Word document.
Most likely, but you must look to fix the problem at the level of diagnosis, not fire-fight the symptoms away.
Look into the code which utilises
Word
Localise the piece of code which
could cause failure
Find particular solutions to the
found problem
Correct the issue
Don't look to 'auto-click' the dialog away or any other such flakiness, this is a hack.
The code in question would be useful, if not invaluable to providing real help.
I have similar problem dealing with PowerPoint in .Net
the safe-mode message box will show up when I launch it from my program after PowerPoint crashed, which stopped my automatically process
after some investigation into the registry, deleting this
HKCU\Software\Microsoft\Office\15.0\PowerPoint\Resiliency (change the Product and Version)
before starting the Office program will avoid the Safe-mode
(This registry key stores the info of last opened file, by deleting this, PowerPoint won't know it was crashed, so it opens normally)
I'm trying to make a video recording application for a project and was wondering if there was anyway to make the OpenFileDialog open up in a modeless diaglog box or would I have to make my own custom version? The reason I ask is the ShowDialog() function freezes my video. Thanks in advance for the help.
Yes, you can prevent a file dialog from blocking the UI thread, but it can be rather non-trivial depending on the details of how you want it to behave. If you're open to buying a component that does this automatically, ComponentAge offers one. Otherwise, you can roll your own by opening the dialog on a spawned thread. If you want the dialog to appear modal to the form that opened it, you'll need to do some extra work to trap the handle of the opened dialog so that you can set focus to it when the parent form is activated. An example is available at http://www.codeproject.com/KB/dialog/CustomizeFileDialog.aspx.
We have C# code in a PowerPoint Addin for custom printing. In Office 2003,
SendKeys.Send("^+{F12}");
works fine to bring up the Print Dialog after doing some stuff.
But in Office 2007 it does not, instead just sending the document to the printer without the dialog.
Getting the Dialog is very important.
using "^{p}" or "^p" as the string will acheive the same thing, no dialog.
Executing the command via:
Application.CommandBars.ExecuteMso("FilePrint");
will also acheive the same thing, no dialog.
Any clues, tips or suggestions as to how can I may get the Print Dialog to appear would be most appreciated.
For the record, here's how I was able to eventually get this working, but i dont fully understand why.
three things required (all necessary)
- use ExecuteMso instead of SendKeys
- remove code prior to print which selected a particular slide
- add call to Application.DoEvents() after ExecuteMso()
Also works OK with Select code restored, but after the Print call, and also including a DoEvents() call.
This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
C# OpenFileDialog Non-Modal possible
I am working on a C# Windows Form project. While an open file dialog is up I am not able to select anything around it in the GUI. Is there any way to have the openfile dialog open and still be able to select other controls on the main ui?
There is no way to do this with the standard OpenFileDialog. You'd need to make your own, using a Form instead of a FileDialog as the base class. This would let you design your own version that was non-modal.
That being said, I'd recommend against this. File dialogs, in Windows, are modal by default. People expect this behavior from your application - so changing it will only lead to confusion and problems. This tends to make your application less usable and more complicated to end users, even though it often seems like a good idea.
The common dialogs are modal dialogs, which by definition do not allow interaction with any other window in the process while they are active. So the answer to your question is no, there isn't any way to do that. You would have to roll your own dialog using third party or self created controls to interact with the file system -- not a trivial task.
dban,
The OpenFileDialog class does not support the Show method which will open a form in a modeless state, that is, not locking out the parent.
As far as i know the only way to open the file dialog is like this, and it is modal. The ShowDialog method open forms as modal.
OpenFileDialog dlg = new OpenFileDialog();
dlg.ShowDialog();
You could write your own open file dialog class if you want it to be open non-modally.
But you should also consider whether this is really necessary or not. Typically when a user is presented with a file open dialog it is because the application needs a file. There is nothing else the user should be doing with the app in the mean time.