combobox on an outlook form with VBscript

G

Guest

I am new to outlook and to programming so i am struggiling. I have had one VB
class about 2 years ago. I am trying to fill a combobox with vbscript code.
After reading a few articles and trying to peice everything together this is
what i have done.

Option Explicit
dim Control

Sub cbosubject_click()
Set Page = Item.GetInspector.ModifiedFormPages("PickOne")
Set Control = Page.Controls("cbosubject")
Control.additem "Marketing"
Control.additem "Sales"
End sub

PickOne is the name of the form and
cbosubject is the name of the combobox

Thanks in advance
 
G

Guest

More info
When i run the form nothing appears in the combobox. I have saved the form
and posted the form. Is there something wrong with my code or am i missing a
step regarding the form?
 
H

Hollis D. Paul

Set Page = Item.GetInspector.ModifiedFormPages("PickOne")
Set Control = Page.Controls("cbosubject")
Control.additem "Marketing"
Control.additem "Sales"
It looks like you should be putting that in the Item_Open function.
Then you publish the form to the appropriate forms library, or your
inbox. You don't really save a form design--instead, you publish it.
You can test the form by clicking the Action menu, choosing run this
form, and seeing how it executes. When done with the test, you delete
it without saving, or it becomes a bit of trash in your default folder.

You publish from the Tools menu: Click Tools --> Forms --> Publish
Forms as and then follow the wizard. Always use Publish As, so that
you can include the version number in the new form name--myform_ver101.
This will prevent the forms cache problem where you swear you
published a new version but when you select the name you get the old
version.

With respect to your code, the Primary Resources for coding information
on the web is www.slipstick.com, www.outlook-tips.net,
www.outlookcode.com. Lesser resources are the web sites of other
Outlook MVPs, a short list of which can be found at:
http://www.outlookbythesound.com/SBS2003/12frameset_outlook.htm, hold
your mouse over the blossoms and buds, and the site name will appear in
the tool-tip.

Hollis D. Paul [MVP - Outlook]
(e-mail address removed)
Mukilteo, WA USA
 
G

Guest

I modified my code to look like this:

Option Explicit
dim Control
function Item_Open()
dim Page
Set Page = Item.GetInspector.ModifiedFormPages("PickOne")
Set Control = Page.Controls("cbosubject")
'Set Control = Nothing
call subject
end function
sub subject()
Control.additem "Marketing"
Control.additem "Sales"

It is now working - Thanks for your help


Hollis D. Paul said:
Set Page = Item.GetInspector.ModifiedFormPages("PickOne")
Set Control = Page.Controls("cbosubject")
Control.additem "Marketing"
Control.additem "Sales"
It looks like you should be putting that in the Item_Open function.
Then you publish the form to the appropriate forms library, or your
inbox. You don't really save a form design--instead, you publish it.
You can test the form by clicking the Action menu, choosing run this
form, and seeing how it executes. When done with the test, you delete
it without saving, or it becomes a bit of trash in your default folder.

You publish from the Tools menu: Click Tools --> Forms --> Publish
Forms as and then follow the wizard. Always use Publish As, so that
you can include the version number in the new form name--myform_ver101.
This will prevent the forms cache problem where you swear you
published a new version but when you select the name you get the old
version.

With respect to your code, the Primary Resources for coding information
on the web is www.slipstick.com, www.outlook-tips.net,
www.outlookcode.com. Lesser resources are the web sites of other
Outlook MVPs, a short list of which can be found at:
http://www.outlookbythesound.com/SBS2003/12frameset_outlook.htm, hold
your mouse over the blossoms and buds, and the site name will appear in
the tool-tip.

Hollis D. Paul [MVP - Outlook]
(e-mail address removed)
Mukilteo, WA USA
 
G

Guest

I modified my code to look like this:

Option Explicit
dim Control
function Item_Open()
dim Page
Set Page = Item.GetInspector.ModifiedFormPages("PickOne")
Set Control = Page.Controls("cbosubject")
'Set Control = Nothing
call subject
end function
sub subject()
Control.additem "Marketing"
Control.additem "Sales"

It is now working - Thanks for your help


Hollis D. Paul said:
Set Page = Item.GetInspector.ModifiedFormPages("PickOne")
Set Control = Page.Controls("cbosubject")
Control.additem "Marketing"
Control.additem "Sales"
It looks like you should be putting that in the Item_Open function.
Then you publish the form to the appropriate forms library, or your
inbox. You don't really save a form design--instead, you publish it.
You can test the form by clicking the Action menu, choosing run this
form, and seeing how it executes. When done with the test, you delete
it without saving, or it becomes a bit of trash in your default folder.

You publish from the Tools menu: Click Tools --> Forms --> Publish
Forms as and then follow the wizard. Always use Publish As, so that
you can include the version number in the new form name--myform_ver101.
This will prevent the forms cache problem where you swear you
published a new version but when you select the name you get the old
version.

With respect to your code, the Primary Resources for coding information
on the web is www.slipstick.com, www.outlook-tips.net,
www.outlookcode.com. Lesser resources are the web sites of other
Outlook MVPs, a short list of which can be found at:
http://www.outlookbythesound.com/SBS2003/12frameset_outlook.htm, hold
your mouse over the blossoms and buds, and the site name will appear in
the tool-tip.

Hollis D. Paul [MVP - Outlook]
(e-mail address removed)
Mukilteo, WA USA
 

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