VB Script in Outlook (2000)

Can anyone give me some VB Script to use on the Open event of an Outlook 2000 form which will open Excel, read a small spreadsheet and use the contents of column 1 to populate a combobox on the Outlook form? Thanks. I know VBA but am struggling in VB Script for this. Thanks again.

Re: VB Script in Outlook (2000)

VBScript is similar to VBA, but the variables are not strongly typed so everything is late bound, that is:

dim xlApp as Object
set xlApp = CreateObject("Excel.Application")

and so forth. It would be easier to develop in the VBA environment using early binding (dim xlApp as Excel.Application) and then covert it to VBScript than to write VBScript from scratch. At least, it usually is for me. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Footnote: I don't know the object model for comboboxes on Outlook forms. Hopefully this can be found in the product's online help.

Re: VB Script in Outlook (2000)

Thanks Rory, though at the moment, having removed the 'As Integer' and 'As Object' from the Dim lines (they were objected to), I'm getting script errors on line 7, the Workbooks.Open statement - any ideas why? Thanks

Re: VB Script in Outlook (2000)

Well, it certainly gets past the Dim statements without the very cryptic error messages it got before ("Expected Statement. Line number x"), but now it's getting an error message (same one) on the Workbooks.Open statement - any ideas why? Thanks.

Re: VB Script in Outlook (2000)

Sorry for late reply, Rory, but yes that worked (removing the "FileName:="). Now I'm battling with getting the AddItem statement to work! Objects to it with and without the MyItem. prefix. But if it's not an AddItem method to populate the ComboBox, what is it? Thanks for your help.

Re: VB Script in Outlook (2000)

Rory,

You're on the button! I'd just sussed that out myself (found a script example on the net), so now I'm coding:
Set CB = Item.GetInspector.ModifiedFormPages("Message").Com boBox7
CB.AddItem myapp.workbooks(1).sheets(1).cells(intindex,1)
and this works fine!
So now I'm a happy bunny, and I'll be using this technique to populate comboboxes on a number of forms where the data changes occasionally, such as current project name, current releases etc. Beats the hell out of having to change the controls in each and every form!
Thanks for all your help, Rory - once again, couldn't have done it without the Lounge! Thanks.