DeskMonkey
03-24-2012, 06:08 PM
Hi all,
I have located the following code and set up 2 comboboxes on my message (combobox 1&2), but the code fails to work.
Can anyone see why it might not?
Function Item_Open()
Call TestR2A
End Function
Sub TestR2A()
Dim ex ' As Excel.Application
Dim ws ' As Excel.Worksheet
Dim rg ' As Excel.Range
Dim arr
Set xlApp = GetObject("C:\Users\User\Desktop\Test.xlsx").Application
Set Mybook=ex.workbooks.open("C:\Users\User\Desktop\Test.xlsx")
Set rg = ex.worksheets(1).Range("A2", "C4")
Call RangeToArray(rg, arr)
Set ListBox1 = Item.GetInspector.ModifiedFormPages("Message").Controls("ListBox1")
ListBox1.List = arr
End Sub
Function RangeToArray(ByVal rngInput, ByRef avValues)
On Error Resume Next
avValues = rngInput.Value
If Err = 0 Then
RangeToArray = avValues
End If
End Function
Using Outlook 2007 and the error at the monent (and I say this as it is the 5th different error I've had) is:
Object Required "ex" Line Number 12
Which is:
Set Mybook=ex.workbooks.open("C:\Users\User\Desktop\Test.xlsx"
Thanks in advance!
I have located the following code and set up 2 comboboxes on my message (combobox 1&2), but the code fails to work.
Can anyone see why it might not?
Function Item_Open()
Call TestR2A
End Function
Sub TestR2A()
Dim ex ' As Excel.Application
Dim ws ' As Excel.Worksheet
Dim rg ' As Excel.Range
Dim arr
Set xlApp = GetObject("C:\Users\User\Desktop\Test.xlsx").Application
Set Mybook=ex.workbooks.open("C:\Users\User\Desktop\Test.xlsx")
Set rg = ex.worksheets(1).Range("A2", "C4")
Call RangeToArray(rg, arr)
Set ListBox1 = Item.GetInspector.ModifiedFormPages("Message").Controls("ListBox1")
ListBox1.List = arr
End Sub
Function RangeToArray(ByVal rngInput, ByRef avValues)
On Error Resume Next
avValues = rngInput.Value
If Err = 0 Then
RangeToArray = avValues
End If
End Function
Using Outlook 2007 and the error at the monent (and I say this as it is the 5th different error I've had) is:
Object Required "ex" Line Number 12
Which is:
Set Mybook=ex.workbooks.open("C:\Users\User\Desktop\Test.xlsx"
Thanks in advance!