MailMerge -- exception in AddIn

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

MailMerge -- exception in AddIn
 
Uwe Thaden


Guest


Hi, I use this mehod as onClick

var
sPath, format: OleVariant;
rg: Range;
Start, Finish: OleVariant;
doc: _Document;
begin
sPath:='c:\input.rtf';

WordApp.ActiveDocument.MailMerge.OpenDataSource(sPath, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);

Start := 0;
Finish := 0;



Rg := WordApp.ActiveDocument.Range(Start, Finish);
doc := WordApp.ActiveDocument;
WordApp.ActiveDocument.MailMerge.MainDocumentType := wdFormLetters;

WordApp.ActiveDocument.MailMerge.Fields.Add(rg, 'Vorname');

WordApp.ActiveDocument.MailMerge.Destination := wdSendToNewDocument;

WordApp.ActiveDocument.MailMerge.MailAsAttachment := False;

format := false;
WordApp.ActiveDocument.MailMerge.Execute(format);


The letter is created as a new document, but the I get an exception. If I place a ShowMessage as last line, it is displayed and after clicking ok I get the exception. The method ends directly, there is no more code.

I used the code in other applications which do not use adx. Thus, I have no idea what the reason could be.

Any help?

Thanks,
Uwe
Posted 19 Mar, 2005 09:27:02 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Uwe,

I have tried your code and see no exceptions. Could you please send me the whole project.


Posted 20 Mar, 2005 09:31:41 Top
Guest


Guest


Hi Dmitry,

it's in the middle of a bigger project; thus, it's hard to extract it for you as a separate project.

Maybe you can provide me your test-project? Then I can check if it works and then investigate the problem in detail.

Thanks,
Uwe

uwe AT thaden DOT de
Posted 20 Mar, 2005 12:57:44 Top
Guest


Guest


You are right!!

There is no problem when I try it in a separate project.

Thus, I have no idea what thre could be different...

I'll try some more.

--Uwe
Posted 20 Mar, 2005 13:34:45 Top
Guest


Guest


Ok, I found out that it is this what causes the problem:

I have two TForms which I create in AddInModuleAddInInitialize:

Application.CreateForm(TFormImport, FormImport);
Application.CreateForm(TFormOptions, FormOptions);

If I remove the two lines, it works without problem.

Do you have any idea what the reason could be?

Thanks,
Uwe
Posted 20 Mar, 2005 13:42:12 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Uwe,

No ideas so far. Did you use any third-party components on your forms? I will try to reproduce this on our test PC.



Posted 21 Mar, 2005 08:29:34 Top
Uwe Thaden




Posts: 13
Joined: 2005-03-08
I use a Grid which is connected to a DB in a TDataModule (created in the same way as the TForm).

As far as I tested it, only this form makes problems. I have tested a simple one with only one TLabel -- no problem.

Can I not use a DB in an AddIn?

Thanks,
Uwe
Posted 21 Mar, 2005 08:55:32 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Uwe,

Can I not use a DB in an AddIn?

I see no reasons that prohibit doing this.

Maybe you can provide me your test-project?

Sure, I have just added TDataModule:
http://www.add-in-express.com/projects/adx-wd-mail-merge.zip



Posted 21 Mar, 2005 09:26:52 Top
Guest


Guest


Maybe I do not free all the things correctly. Sounds somehow like the problem when creating items dynamically. Maybe I can somehow get removed all my AddIn from Word?

--Uwe
Posted 21 Mar, 2005 10:06:30 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Uwe,

Maybe I can somehow get removed all my AddIn from Word?

Unregister all your add-ins. Open the COM Add-ins dialog box in MS Word and make sure there are no add-ins in the list. Close MS Word and remove normal.dot. It seems that's all.




Posted 21 Mar, 2005 12:41:46 Top