VBScript / SetFocus Chaos in Outlook 2003

D

Daryll Combs

I am a long term Access VBA developer working deeply for first time in
Outlook forms, coding and object model. Let me say this right from the
start.....VBScript is an absolutely dreadful development environment and the
more I work with it the less I like it. I will never understand how Microsoft
rationalizes such a widely disparate set of development capabilities between
Outlook's crippled environment and the robust capabilities found in most if
not all of the other members of the Microsoft Office suite. OK, that said and
out of the way, I am struggling with being able to set the focus to any of
the controls that exist on a specific page of a multipage control. I have a
multipage control that has 14 predefined and formatted pages. Based upon a
selection from a combo box dropdown list located in the upper area of the
form and not part of the multipage control my desire is to disable all
multipage pages except the one that corresponds to item chosen in drop down
list and then to move focus to the remaining enabled page. I have worked for
more then 10 hours to accomplish this and have coded failed construct after
construct in the attempt of accomplishing what should be a very simple
task....simple at least in other applications that have a real development
environment. If anyone has any experience with this inane problem and ideas
for possible workarounds or other code constructs that might achieve the
desired result I would love to hear from them here. Sorry for the venting
throughout this post but too many of my experiences with undertaking Outlook
extensibility projects over the past couple of years have proven to be just
dreadful due to these kinds of nuisance issues that do nothing but burn
valuable hours and leave me scratching my head about what in the world
Microsoft was thinking when they knowingly unleash and then continue to leave
in place this kind of degraded work environment in an application that is as
heavily used throughout the world as is Outlook. I just dont get it, I am
sorry to say. Thanks again for listening.
 
S

Sue Mosher [MVP-Outlook]

Is this on an Outlook VBA user form or on an Outlook custom form? It sounds like an Outlook form, but you posted in the VBA group, so we need to get clarification on that.

If it is a custom form, not a VBA form, is the combo box bound to a custom Outlook property, a standard property, or unbound?
I will never understand how Microsoft
rationalizes such a widely disparate set of development capabilities between
Outlook's crippled environment and the robust capabilities found in most if
not all of the other members of the Microsoft Office suite.

They don't. Instead, they change. Outlook UI development has moved with Outlook 2007 to form regions and custom task panes -- much more robust than traditional Outlook custom forms.
 
D

Daryll Combs

Sue,

Thanks for your response. I have your Outlook 2007 book and it is a great
read and resource. I have it sitting on page 387 where you describe the use
of the setfocus method as a way of validating user form input. I have used
setfocus method thousands of time in Access and would have never guessed that
doing so in Outlook would be a challenge. So, it is an Outlook custom form
using VBScript. My research and recommendations from others about which
environment to work in for Outlook customization convinced me that VBScript
would be lesser of two evils, but given what pain I have endured so far I am
not entirely sure that I made the right choice, but everything I looked at
warned me to stay away from VBA since it was a single instance model per
Outlook client instance. I posted into VBA forum because I did not see a
VBScript specific group and the other programming topic seemed to be Outlook
forms only. Sorry if I posted into wrong channel. Thanks.

--
W. Daryll Combs
Jennica Data Systems Inc.
Cincinnati OH
 
D

Daryll Combs

Also, the combo box is bound to a custom Outlook property and the form type
that I am working from for the customization is a post-form. Thanks.

--
W. Daryll Combs
Jennica Data Systems Inc.
Cincinnati OH
 
S

Sue Mosher [MVP-Outlook]

The newsgroup for custom form issues is right "down the hall" from this one -- microsoft.public.outlook.program_forms.

This CustomPropertyChange event handler assumes the following:

* Combo box is bound to a text property named ComboField with possible values "red" and "blue"
* Custom page named P.2
* Multipage control named MultiPage1 with two pages
* On each page are two text boxes. TextBox2 is on page 1. TextBox4 is on page 2. (Each page also has another text box.)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "ComboField" Then
Set pg = Item.GetInspector.ModifiedFormPages("P.2")
Set MultiPage1 = pg.Controls("MultiPage1")
If Item.UserProperties("ComboField") = "red" Then
MultiPage1.Pages(0).Visible = False
MultiPage1.Pages(1).Visible = True
MultiPage1.Value = 1
Set TextBox = MultiPage1.Pages(1).Controls("TextBox4")
TextBox.SetFocus
Else
MultiPage1.Pages(1).Visible = False
MultiPage1.Pages(0).Visible = True
MultiPage1.Value = 0
Set TextBox = MultiPage1.Pages(0).Controls("TextBox2")
TextBox.SetFocus
End If
End If
End Sub

The most important thing to notice is that you cannot set the Value of a multipage control to the index of page that is not visible. You need to make it visible first. The same probably goes for the Enabled property, if you're leaving pages visible, but disabled. I didn't test that, though.
 
D

Daryll Combs

Sue,

I wrote a very lengthy reply in the last half hour or so about the success
that I achieved in resolving my problem with the very elegant solution that
you provided. Just as I hit the post button, given the skittish nature of
internet web pages, I thought to myself I should probably copy the text of
this message to the clipboard in case the web page or posting process fails.
Sure enough it did, and I lost all of my ruminations about the terrific help
that I received from you today and my frustrations with using Microsoft's
paid support services to get help on issues like this one today. Bottom line
then, the helpful solution you provided worked like a charm and I would be
interested in talking with you further at some point about any kind of paid
consulting/technical support services that you might presently be providing
to Outlook developers like myself that are still very early in the learning
curve. Please let me know your thoughts on that and possibly some ways that I
could discuss this with you further outside of here if that is something that
is of interest to you. Again, the solution was awesome, your
knowledge/experience are amazing, your kindness in monitoring these
communities to help other people is admirable and appreciated, your latest
book has already been of substantial ground-level benefit to me as I try to
grasp the Outlook object model, even though it was written for Outlook-2007
and I am developing in Outlook-2003. So then, thank you on those several
fronts for your help and kindness. Take care and I hope to have an
opportunity to talk with you soon....and oh by the way, this time I will
paste a copy of the message on the clipboard, just in case.
Daryll Combs



W. Daryll Combs
Jennica Data Systems Inc.
Cincinnati OH
 
S

Sue Mosher [MVP-Outlook]

I'm glad it worked for you. It makes a nice addition to our collection of practical Outlook form scenarios; I've posted the sample at http://www.outlookcode.com/codedetail.aspx?id=1764.

I don't provide paid help, but if you feel the need for it, you can send a message to outlook-dev-hire at yahoogroups.com with details of your requirements, including the Outlook version(s) to be supported. Once the moderator approves your message, Outlook developers on the outlook-dev-hire list can respond directly to you if they're interested in your project.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 

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