Unusual behaviour when using Dialogs (Word 2007/Word 2010)

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Unusual behaviour when using Dialogs (Word 2007/Word 2010)

Post by Jack21 »

Hi all

I am seeing some unusual behaviour when using Dialogs and wondered if anyone else has come across this. I have developed a ribbon in VB.Net which, when the user selects the option "Labels" from the drop down I call the relevant dialog box:

appWord.Dialogs(Word.WdWordDialog.wdDialogToolsEnvelopesAndLabels).Show()

I then insert a delivery address, return address, set the return address as default and then select create a new document, all works as expected. If I then click on the "Labels" option via my developed ribbon the dialog box will appear with no delivery address or return address visible. If I then go to the Mailings ribbon and select "Envelopes" both the delivery address and return address is visible.

Can anyone shed any light?

Thanks as always
Jack

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Unusual behaviour when using Dialogs (Word 2007/Word 201

Post by HansV »

To get the current address into the dialog, you can use

Code: Select all

With appWord.Dialogs(Word.WdWordDialog.wdDialogToolsEnvelopesAndLabels)
    .AddrText = appWord.ActiveDocument.Envelope.Address
    .Show()
End With
Howver, I can't get it to fill in the return address. The following should work, in theory:

Code: Select all

    .RetAddrText = appWord.ActiveDocument.Envelope.ReturnAddress
but it doesn't do anything when I try it.

(See Built-in Dialog Box Argument Lists (Word))
Best wishes,
Hans

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Unusual behaviour when using Dialogs (Word 2007/Word 201

Post by Jack21 »

Thanks as always Hans.

I have run the code and can clearly see that I have a delivery address (appWord.ActiveDocument.Envelope.Address) and a return address (appWord.ActiveDocument.Envelope.ReturnAddress) but on opening the dialog box neither appear. I have a strong feeling we have found a Microsoft bug !!

Regards
Jack

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Unusual behaviour when using Dialogs (Word 2007/Word 201

Post by HansV »

I also tried

appWord.CommandBars.FindControl(ID:=794).Execute

The addresses were briefly displayed in the dialog, then cleared... :hairout:

As a workaround, you could create a form that displays appWord.ActiveDocument.Envelope.Address and appWord.ActiveDocument.Envelope.ReturnAddress in text boxes so that the user can edit them. When the user clicks OK, use appWord.ActiveDocument.Envelope.Insert to insert/change the envelope. See Envelope.Insert Method (Word).
Best wishes,
Hans

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Unusual behaviour when using Dialogs (Word 2007/Word 201

Post by Jack21 »

Thanks again Hans.

I tried the CommandBars options and it did actually work but I did note that the delivery address was highlighted as the dialog box appeared. We have a Microsoft Consultant on site and he feels that this is a bug and will be delving a little deeper to see if anything comes up. No one in the firm has raised this issue so I will leave as is for now and see whether the Microsoft Consultant comes up with anything.

Regards
Jackie