Overriding FileOpen

Add-in Express™ Support Service
That's what is more important than anything else

Overriding FileOpen
Overriding FileOpen NOT the OnDocumentOpen event 
Roger Middlebrook


I would like to override the command FileOpen in Word. I have tried to do it with an adxBuiltInControl (BIC) but, for some reason, this makes Word think the Normal template has been modified.

I have tried BIC with and without an adxCommandBar and I use BuiltInID := 23.

This is Delphi 7 with ADX

Am I taking the wrong approach?
Posted 27 Jun, 2006 13:20:13 Top
David Golden

Posts: 11
Joined: 2006-03-07

Update to v2.6 of the VCL edition and see if that fixes the issue with the dirty template.

If that doesn't fix it, you can use something similar to the following code.

procedure TAddInModule.adxWordAppEventsDocumentBeforeClose(
  ASender: TObject; const Doc: _Document; var Cancel: WordBool);
  iX: Integer;
  index: OleVariant;
  if not WordApp.NormalTemplate.Saved then
    WordApp.NormalTemplate.Saved := True;
  for iX := 1 to WordApp.Templates.Count do begin
    index := iX;
    if not WordApp.Templates.Item(index).Saved then
      WordApp.Templates.Item(index).Saved := True;

Note. Some of that may be redundant, however I haven't had time to modify it.

Hope that helps

David Golden.
Posted 27 Jun, 2006 21:16:53 Top
Roger Middlebrook


Thanks for this, David.

As it happens, the fault was in my code. I was handling the OnDocumentBeforeSave event (which is, of course, called when the Normal template is saved) and my handler was preventing the Normal template from being saved correctly.

Nothing to do with the BuiltInControl, not ADX's fault... all my fault.
Posted 28 Jun, 2006 04:19:28 Top