vbscript help/advice

G

Guest

Hi,

I'm a newbie at VBA and have absolutely no knowledge of working with vbscript in general or within Outlook

I'm trying to set up two new Outlook forms at work. Although I can set the design elements that make up the forms, I have no idea how to script the events. What I want to accomplish is as follows: -

1. The first form has a number of commandbuttons and associated text boxes. I would like a script which will populate the associated text box with the current time and render the commandbutton inactive and the associated textbox read only.

There are three further text boxes associated with the time text box. I need these to pervent users from sending the e-mail if these are not completed. I'm assuming this can be accomplished by using validation rules. Further advice on this would be appreciated.

2. The second form has a listbox on the first page, with several further, hidden pages. Based on the option chosen by the user from the listbox, I would like one of the hidden pages to become visible whilst hiding the first page. I also need it to populate the "To:" field with a specific distribution list based on the choice.

Also, is if I wasn't asking too much already, could you please lend some advice on suitable material on the subjects of both vbscript, especially in relation to Outlook forms, and vba?

Thanks in advance to anyone who can spare the time to assist a novice.

Mike
 
S

Sue Mosher [MVP-Outlook]

You might want to start with the samples listed at
http://www.outlookcode.com/d/forms.htm and
http://www.outlookcode.com/d/vbscript.htm.

The page at http://www.outlookcode.com/d/propsyntax.htm explains how to
access both Outlook properties and unbound form controls and change the
controls' attributes in response to user actions on the form. Here are some
pieces of information that you will need to get started, beyond your
description below:

1) Are the text boxes bound to Outlook properties? If so, what?

2) Is the list box bound to an Outlook property? If so, what?

3) Should it be possible to add more than one DL to the To field? Or just
one?

4) *When* do you want the associated text boxes to be populated with the
current time?

You'll also find it useful to learn how to use the object browser to look up
the available properties and methods. Press ALt+F11 to open the VBA
environment in Outlook, then press F2. Switch from <All Libraries> to
Outlook to browse all Outlook objects and their properties, methods, and
events. Select any object or member, then press F1 to see its Help topic.

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



UKNewbie said:
Hi,

I'm a newbie at VBA and have absolutely no knowledge of working with
vbscript in general or within Outlook
I'm trying to set up two new Outlook forms at work. Although I can set the
design elements that make up the forms, I have no idea how to script the
events. What I want to accomplish is as follows: -
1. The first form has a number of commandbuttons and associated text
boxes. I would like a script which will populate the associated text box
with the current time and render the commandbutton inactive and the
associated textbox read only.
There are three further text boxes associated with the time text box. I
need these to pervent users from sending the e-mail if these are not
completed. I'm assuming this can be accomplished by using validation rules.
Further advice on this would be appreciated.
2. The second form has a listbox on the first page, with several further,
hidden pages. Based on the option chosen by the user from the listbox, I
would like one of the hidden pages to become visible whilst hiding the first
page. I also need it to populate the "To:" field with a specific
distribution list based on the choice.
Also, is if I wasn't asking too much already, could you please lend some
advice on suitable material on the subjects of both vbscript, especially in
relation to Outlook forms, and vba?
 
G

Guest

Thanks, Sue. I didn't expect such a speedy response and am grateful you have.

I shall take a look at the links you have provided. Can you also suggest a book or two I can use offline?

In answer to your questions, or at least as best as I can answer them.

1. I've set a user defined property for each textbox called, simply, Time1, Time2, etc.

2. I haven't worked out how best to use this option. I'm thinking that it may be easier to assign variables in response to a the value of a property? Advice on this would be appreciated.

3. The DL would vary in response to what option the user selects in the listbox. For example, if the user selects "Leaver", this would incl. Personnel, Scheduling and Recruitment. If the user selects "Mover", this would incl. Personnel, Scheduling and the relevant departmental contact.

4. The text boxes would be populated upon the user clicking the associated command button. I can accomplish this using VBA in Office Apps but have no idea how to handle objects in vbscript.

Thanks again. I'll go and have a browse of those links whilst I wait for your reply.

Mike.
 
G

Guest

I've done a bit of reading and at least figured out 1 part of a solution.

For example, to update a TextBox1, whose value is "Time1", I can use: -

Sub CommandButton1_Click()
Item.UserProperties("Time1")=Now()
End Sub

All I need to do is find out how to delete/remove the CommandButton1 object and make TextBox1 read only. I think I need to learn how to manipulate control objects and their properties.

I'm not sure if we are meant to post our progress. If not, let me know. TY.

Mike
 
S

Sue Mosher [MVP-Outlook]

Progress is to be celebrated! Did you take a look at the examples at
http://www.outlookcode.com/d/propsyntax.htm#unbound? section? That will show
you how to hide (NOTE: not remove) and disable controls by setting their
properties.

As for your earlier question on books, see my signature.

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



UKNewbie said:
I've done a bit of reading and at least figured out 1 part of a solution.

For example, to update a TextBox1, whose value is "Time1", I can use: -

Sub CommandButton1_Click()
Item.UserProperties("Time1")=Now()
End Sub

All I need to do is find out how to delete/remove the CommandButton1
object and make TextBox1 read only. I think I need to learn how to
manipulate control objects and their properties.
I'm not sure if we are meant to post our progress. If not, let me know.
TY.
 
G

Guest

I've been making steady progress through a number of resources, including your own. I've not checked the "unbound" section yet but, I will visit this very soon.

One more, hopefully, quick question I haven't yet figured out.

I have a row of 5 textboxes which all need to be completed if the first textbox is other than empty. If they are not, I want to prevent the user from sending the e-mail. I've tried fiddling with the validation settings but haven't quite figured it out.

Any tips or solutions to this would be fantastic.

By the way, thanks for all the pointers so far - it's a refreshingly nice change to be given the opportunity to learn by trial and error, rather than having it handed to you on a plate, or being faced with an incredulous and condesceding attitude.

Mike.
 
S

Sue Mosher [MVP-Outlook]

Validation formulas need to evaluate to True if the data is good and False
if it's not. In your situation, one good case is if the first textbox
(Field1) is empty, so that condition is:

[Field1] = ""

Put that with the need to put data in one of the other textboxes (Field2)and
you get:

([Field1] = "") OR ([Field2 <> "")

This will return True either if Field1 is blank or if Field2 has data in it.
Repeat as needed for the other 4 boxes, and you should be pretty close.

For more info on formulas, check the articles listed at
http://www.outlookcode.com/d/forms.htm#formulas

BTW, you can learn a lot making mistakes with Outlook. I do it every day.

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



UKNewbie said:
I've been making steady progress through a number of resources, including
your own. I've not checked the "unbound" section yet but, I will visit this
very soon.
One more, hopefully, quick question I haven't yet figured out.

I have a row of 5 textboxes which all need to be completed if the first
textbox is other than empty. If they are not, I want to prevent the user
from sending the e-mail. I've tried fiddling with the validation settings
but haven't quite figured it out.
Any tips or solutions to this would be fantastic.

By the way, thanks for all the pointers so far - it's a refreshingly nice
change to be given the opportunity to learn by trial and error, rather than
having it handed to you on a plate, or being faced with an incredulous and
condesceding attitude.
 
G

Guest

Sue,

That worked an absolute treat. Took a few minutes to get my head around the concept but once I'd looked at the logic, it was very easy to see how this worked.

Thanks for all the help. I now have 1 working form that I can distribute to relevant departments. Now onto number 2.

Me thinks this one may be more of a challenge so expect a query or two making a bee-line in your direction.

Again, many thanks for all the pointers.

Mike
 

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

Similar Threads


Top