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)
Related
I've an applications that allows a user to start MS Word.
If the user holds the "CTRL" key while starting MS Word, following dialog is shown:
This leads to errors in my application, because users seem to hold the "CTRL" key by accident and may click on "yes", which deactivates my office addins.
Is there a way to prevent Word from showing this dialog and also from starting in safe mode?
For instance, if you try to start Excel with the "\e" parameter + holding "CTRL" key, Excel starts without any dialog and not in safe mode.
The application is developed in .Net (c#)
You tell the user to stop doing that!
AFAIK, There is no way you can, with code or otherwise, stop Word from starting in safe mode. That is a basic diagnostic built into the programs and is not optional.
I am writing a c# application that opens a number of PI ProcessBook display files. PI Processbook is a program that has embedded Visual Basic for Applications support, including a VBE environment.
The problem that I have is that a number of the displays I want to open have macros in them that run automatically when the display is opened. I have set the macro protection to maximum (which should disable macros completely!), but unfortunately there is something in the TypeLibrary that I am using that means that when a file is opened programatically, it bypasses macro security and the macros run anyway. Go figure....
I am therefore trying to find a way to programatically kill these macros, even if they have started. I have tried using SendKeys.Wait("^{BREAK}") to force into break mode. This "works", but is a bit hit-and-miss: I find that if the macro doesn't pause at some point, SetForegroundWindow can't force the VB Editor to the foreground to accept the sendkeys input. I therefore tried using sendmessage. I used SPY++ to see that CTRL+BREAK appears to send a WM_CANCELMODE message to the window. Apparently, this is somehow handled differently from literally ALT+Tabbing or clicking on the window with a mouse and pressing the CTRL+Break keys, in that the message gets queued, but does not appear to process until the macro has finished executing.
Does anyone have any other suggestions of things to try?
I am therefore trying to find a way to programatically kill these
macros, even if they have started.
Hold down the Shift key while opening the Spreadsheet and the Macro's wont run.
Otherwise you could try halting the code while its running: Ctrl + Alt + PauseBreak
Edit:
I have set the macro protection to maximum (which should disable
macros completely!)
Try disabling them:
I'm writing in Visual Studio 2008 using C# (if that makes a difference) and I have the following snippet of code:
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
//Write Stuff to File Here
}
For a while I thought my code that wrote the file was taking forever, however upon debugging it seems to take forever (5 to 10 seconds) just to step between the "if" statement and the first bracket of first code within the "if".
Is there anything I'm doing wrong? Is there any difference between creating the saveFileDialog object in the UI versus creating it on the fly (through code)? Would it make a difference if there is no "else" statement?
Any thoughts or ideas would be greatly appreciated!
This is not unusual, on many machines a ton of DLLs get loaded into your process when you use that dialog. You can see them getting loaded by using Project + Properties, Debug tab, tick the "Enable unmanaged code debugging" checkbox. The Output window shows a trace of every DLL that worms its way into your program.
These are shell extensions, customizations for Explorer. The dialog you use is a shell dialog, you surely recognize the similarity with regular Explorer views. Things like icons and context menus behave the same. Having a lot of shell extensions installed is common on developer's machines, more so than user machines. There are a lot of them out there, offering such conveniences as integrating whatever tool you like to use with Explorer itself.
Debugging the problem isn't that easy, you won't have the actual source code for these extensions. You might get a hint about the troublemaker from the trace in the Output window. If there's a lengthy pause after one particular DLL then odds are good that this DLL is the source of the problem. Nothing really solid though.
The better approach is to use SysInternals' AutoRuns utility. It shows you exactly what shell extensions are installed and allows you to disable them by simply clicking a checkbox. Start disabling anything that doesn't have a Microsoft copyright and stuff you could live without. Logout + Login required to make the changes effective.
I have written an application that changes some of the registry settings and then restarts explorer to save them. Everytime explorer is restarted an annoying "Libraries" popup comes up.
I want to disable it somehow though C# code, (probably by tweaking some other registry keys). However, I do NOT want to disable libraries feature, just a popup that comes up when explorer is restarted.
All articles on the web show how to disable libraries completely.
The most likely reason for this to happen is that the Libraries window was open the last time Explorer was shut down naturally, i.e., the last time the user logged off. If you close the window and log off, then log in again, your software will probably work correctly.
Caveat: killing and restarting the explorer process is inherently risky. Resolving this particular issue does not mean that other similar issues won't show up in future.
When restarting explorer I just had to add some randow parameter as it seems to default to Libraries window. so calling "explorer.exe xxx" would cause explorer to ignore default parameters.
Bit of a weird one this: I've got a shared Office addin that currently targets Outlook 2007 on XP and Win7 (Excel/Word and other versions later). It adds a toolbar button, and this fires off my code. My code just reads data from Outlook. First time round, it works a treat. Second time, the button click does nothing. No errors, nothing. The rest of Outlook responds as normal.
The entire event code is in a try/catch that writes any exceptions out to a temporary file (this mechanism works if a throw an exception in code), but nothing is picked up.
According to the "Trust Center", my addin is active (not inactive or disabled). If I restart Outlook, or stop and start the addin via the Trust Center, it again works once and then stops.
If I reduce the amount of work my code does, the button will sometimes respond for about ten clicks or so, then gives up. Whichever version of my code I try, resources don't seem to change much (memory moves up a mite, the thread count stays the same).
I've read of a similar thing with Word, but this was explained by Word recreating the toolbars or menus every time it loads a document (not sure how correct this is). For me, I select an email, click once, it works, click again (no changing views in Outlook, selecting different emails, etc), and it doesn't.
Has anybody got any clues here?
You should place the variable that contains your toolbar buttons to a global scope (You can keep then as fields of the addin object). If you don't keep a valid path to them at all times, .NET garbage collector will eventually clean up these objects and the event handlers with it. This will however not remove the visible button so it will still be visible.