Determine currently displayed address?

B

Bill James

The SelectedMailingAddress property (olBusiness,olHome,olNone,olOther) of a
ContactItem denotes which address has been selected as the mailing
address...

Is is possible to determine which address is currently being displayed when
viewing a contact item?
 
M

Michael Bauer

Hi Bill,

it´s not possible with the OOM. With some Win32 APIs instead you could
get the label´s caption left from the dropdown button - but that´s a lot
of work.
 
B

Bill James

Thank you for your response. You wouldn't by chance have an example of how
that Win32 API is used?

I'm assuming the name of the controls on the form can be found in design
mode properties dialog...
 
M

Michael Bauer

Hi Bill,

unfortunately here is no script ready.

The controls on the Contact Form are hierarchycally structured. The
hierarchy for the needed part in OL 2000 is somewhat like:

Desktop
- OL-Inspector
- Class name="AfxWnd"
- First child
- First child
- 11. sibling

These APIs you´d need:

- GetDesktopWindow
- GetWindow
- GetWindowText
- GetClassName
- SendMessage

You can find the declaration and some samples under e.g.
www.mentalis.org
 
S

Sue Mosher [MVP-Outlook]

Actually, it is possible with the Outlook object model, but at a pretty steep cost: You wind up one-offing the form. If the item is already using a custom form, though, that's not an issue and it's pretty simple:

Set generalPage = myItem.GetInspector.ModifiedFormPages("General")
Set addrSelLabel = generalPage.Controls("AddressSelectorLabel")
MsgBox addrSelLabel.Caption

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Bill James

Hello Sue,

Thank you for the tip. Your code worked! I simply added code to add a
modified page if none exist:

If (ActiveInspector.ModifiedFormPages.Count = 0) Then
ActiveInspector.ModifiedFormPages.Add ("General")
End If

Debug.Print
ActiveInspector.ModifiedFormPages("General").Controls("AddressSelectorLabel")

Shame that the only way to have direct access to the controls on a form is
to have at least one modified custome form page...

Thanks again

Actually, it is possible with the Outlook object model, but at a pretty
steep cost: You wind up one-offing the form. If the item is already using a
custom form, though, that's not an issue and it's pretty simple:

Set generalPage = myItem.GetInspector.ModifiedFormPages("General")
Set addrSelLabel = generalPage.Controls("AddressSelectorLabel")
MsgBox addrSelLabel.Caption

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Be careful with this. The size of your items may jump by 20k if you aren't already using a custom form with them.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Bill James

I just notice another unwanted sideeffect: after called .Add("General") the
default contact form reverts to one without the [how can I explain it]
Outlook 2003 "look and feel". The buttons are not styled and the layout
looks more like previous version of Outlook.

Any suggestions on how to retain the original look of the Outlook 2003
contact form?

Be careful with this. The size of your items may jump by 20k if you aren't
already using a custom form with them.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

You can't. That's a known side effect of modifying the General page. Again, this is easy if you're already using a custom form, though -- you just put the controls on a custom page and refer to that copy in your code, not the original on the General page. --
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Bill James said:
I just notice another unwanted sideeffect: after called ..Add("General") the
default contact form reverts to one without the [how can I explain it]
Outlook 2003 "look and feel". The buttons are not styled and the layout
looks more like previous version of Outlook.

Any suggestions on how to retain the original look of the Outlook 2003
contact form?

Be careful with this. The size of your items may jump by 20k if you aren't
already using a custom form with them.

Bill James said:
Hello Sue,

Thank you for the tip. Your code worked! I simply added code to add a
modified page if none exist:

If (ActiveInspector.ModifiedFormPages.Count = 0) Then
ActiveInspector.ModifiedFormPages.Add ("General")
End If

Debug.Print
ActiveInspector.ModifiedFormPages("General").Controls("AddressSelectorLabel")

Shame that the only way to have direct access to the controls on a form is
to have at least one modified custome form page...

Thanks again

Actually, it is possible with the Outlook object model, but at a pretty
steep cost: You wind up one-offing the form. If the item is already using
a
custom form, though, that's not an issue and it's pretty simple:

Set generalPage = myItem.GetInspector.ModifiedFormPages("General")
Set addrSelLabel = generalPage.Controls("AddressSelectorLabel")
MsgBox addrSelLabel.Caption
 
B

Bill James

I was just reading your "Customizing Contact Forms" page on outlookcode.com
and I see this as one of the oddities of Outlook...

(Again I'd like to complain to the Outlook developers that the controls on
any (even the default unmodified) Outlook form should be accessible in the
Object Model!)

Thanks for your help Sue.

You can't. That's a known side effect of modifying the General page. Again,
this is easy if you're already using a custom form, though -- you just put
the controls on a custom page and refer to that copy in your code, not the
original on the General page. --
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Bill James said:
I just notice another unwanted sideeffect: after called .Add("General")
the
default contact form reverts to one without the [how can I explain it]
Outlook 2003 "look and feel". The buttons are not styled and the layout
looks more like previous version of Outlook.

Any suggestions on how to retain the original look of the Outlook 2003
contact form?

Be careful with this. The size of your items may jump by 20k if you aren't
already using a custom form with them.

Bill James said:
Hello Sue,

Thank you for the tip. Your code worked! I simply added code to add a
modified page if none exist:

If (ActiveInspector.ModifiedFormPages.Count = 0) Then
ActiveInspector.ModifiedFormPages.Add ("General")
End If

Debug.Print
ActiveInspector.ModifiedFormPages("General").Controls("AddressSelectorLabel")

Shame that the only way to have direct access to the controls on a form
is
to have at least one modified custome form page...

Thanks again

Actually, it is possible with the Outlook object model, but at a pretty
steep cost: You wind up one-offing the form. If the item is already using
a
custom form, though, that's not an issue and it's pretty simple:

Set generalPage = myItem.GetInspector.ModifiedFormPages("General")
Set addrSelLabel = generalPage.Controls("AddressSelectorLabel")
MsgBox addrSelLabel.Caption
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top