Group:  Microsoft Outlook ยป microsoft.public.outlook.program_forms
Thread: Filling listbox on custom Contact item 1st page

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Filling listbox on custom Contact item 1st page
John E. 22.09.2006 06:09:01
I have a custom form for Contacts that has a list box on the 1st page into
which I am reading data from an Excel spreadsheet. Was trying to use the
Join function to do this per pgs 108-109 of Sue's book but can't get past a
run time error on the line that has comment relative to
objItem.lstVisitRequest list box in below code. Can anyone advise me why
this isn't working? Run time error given for this line is #5: Invalid
procedure call or argument, yet it is done in same way as Sue's book.
intRowCount = objRange.Rows.Count
If intRowCount > 0 Then
For Each m_objItem In m_objCurrentFolder.Items
m_strCategories = m_objItem.Categories
If InStr(m_strCategories, "International") > 0 Then
lstVisitRequests.ColumnCount = 4
Dim arrVisitRequests(ListBoxRows, 3)
Dim arrList(ListBoxRows, 3)
For I = 0 To intRowCount
arrVisitRequests(I, 0) = objRange.Cells(I + 1, 1)
arrVisitRequests(I, 1) = objRange.Cells(I + 1, 2)
arrVisitRequests(I, 2) = objRange.Cells(I + 1, 3)
arrVisitRequests(I, 3) = objRange.Cells(I + 1, 4)
Next
' Fill the List Box from the loaded array.
lstVisitRequests.List() = arrVisitRequests
' Fill the List Box in the current contact item
m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
' above line has run time error
m_objItem.Save
End If
Next
End If
--
John E.
Re: Filling listbox on custom Contact item 1st page
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 22.09.2006 09:38:41
If you already have this statement:

lstVisitRequests.List() = arrVisitRequests

I don't understand the purpose of this one:

m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"John E." <je.lodestar[ at ]comcast.net> wrote in message news:9BC4BDD5-5AE2-40B4-81D9-729051A5E277[ at ]microsoft.com...
[Quoted Text]
>I have a custom form for Contacts that has a list box on the 1st page into
> which I am reading data from an Excel spreadsheet. Was trying to use the
> Join function to do this per pgs 108-109 of Sue's book but can't get past a
> run time error on the line that has comment relative to
> objItem.lstVisitRequest list box in below code. Can anyone advise me why
> this isn't working? Run time error given for this line is #5: Invalid
> procedure call or argument, yet it is done in same way as Sue's book.
> intRowCount = objRange.Rows.Count
> If intRowCount > 0 Then
> For Each m_objItem In m_objCurrentFolder.Items
> m_strCategories = m_objItem.Categories
> If InStr(m_strCategories, "International") > 0 Then
> lstVisitRequests.ColumnCount = 4
> Dim arrVisitRequests(ListBoxRows, 3)
> Dim arrList(ListBoxRows, 3)
> For I = 0 To intRowCount
> arrVisitRequests(I, 0) = objRange.Cells(I + 1, 1)
> arrVisitRequests(I, 1) = objRange.Cells(I + 1, 2)
> arrVisitRequests(I, 2) = objRange.Cells(I + 1, 3)
> arrVisitRequests(I, 3) = objRange.Cells(I + 1, 4)
> Next
> ' Fill the List Box from the loaded array.
> lstVisitRequests.List() = arrVisitRequests
> ' Fill the List Box in the current contact item
> m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
> ' above line has run time error
> m_objItem.Save
> End If
> Next
> End If
> --
> John E.
Re: Filling listbox on custom Contact item 1st page
John E. 22.09.2006 16:43:03
Sue,
The line... lstVisitRequests.List() = arrVisitRequests ....reads the array
data into a list box that is resident in the form that is part of my VBA
session and works fine. This is really there to test my read process and
feed process to the list box.
The line....m_objItem.lstVisitRequests = Join(arrVisitRequests, ",").....is
what I am really trying to do, which is fill an identical lstVisitRequests
list box in each objItem as they are being walked thru by the rest of the
code within the For Each...EndIf loop. This list box has identical
properties to the one in the test form referenced above, but resides on the
1st page of the custom form for each contact. Using the Watch feature I
have confirmed that this For Each loop is working properly to walk thru each
contact in the folder. My problem is I can't figure out how to get the
arrVisitRequest data into the list box contained in each objItem list box.

--
John E.


"Sue Mosher [MVP-Outlook]" wrote:

[Quoted Text]
> If you already have this statement:
>
> lstVisitRequests.List() = arrVisitRequests
>
> I don't understand the purpose of this one:
>
> m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
>
> --
> Sue Mosher, Outlook MVP
> Author of Configuring Microsoft Outlook 2003
> http://www.turtleflock.com/olconfig/index.htm
> and Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:9BC4BDD5-5AE2-40B4-81D9-729051A5E277[ at ]microsoft.com...
> >I have a custom form for Contacts that has a list box on the 1st page into
> > which I am reading data from an Excel spreadsheet. Was trying to use the
> > Join function to do this per pgs 108-109 of Sue's book but can't get past a
> > run time error on the line that has comment relative to
> > objItem.lstVisitRequest list box in below code. Can anyone advise me why
> > this isn't working? Run time error given for this line is #5: Invalid
> > procedure call or argument, yet it is done in same way as Sue's book.
> > intRowCount = objRange.Rows.Count
> > If intRowCount > 0 Then
> > For Each m_objItem In m_objCurrentFolder.Items
> > m_strCategories = m_objItem.Categories
> > If InStr(m_strCategories, "International") > 0 Then
> > lstVisitRequests.ColumnCount = 4
> > Dim arrVisitRequests(ListBoxRows, 3)
> > Dim arrList(ListBoxRows, 3)
> > For I = 0 To intRowCount
> > arrVisitRequests(I, 0) = objRange.Cells(I + 1, 1)
> > arrVisitRequests(I, 1) = objRange.Cells(I + 1, 2)
> > arrVisitRequests(I, 2) = objRange.Cells(I + 1, 3)
> > arrVisitRequests(I, 3) = objRange.Cells(I + 1, 4)
> > Next
> > ' Fill the List Box from the loaded array.
> > lstVisitRequests.List() = arrVisitRequests
> > ' Fill the List Box in the current contact item
> > m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
> > ' above line has run time error
> > m_objItem.Save
> > End If
> > Next
> > End If
> > --
> > John E.
>
Re: Filling listbox on custom Contact item 1st page
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 22.09.2006 17:21:55
[Quoted Text]
>> fill an identical lstVisitRequests
> list box in each objItem as they are being walked thru by the rest of the
> code within the For Each...EndIf loop

What you want to do is not possible. Changes to an item's UI -- such as filling a list box -- are not persisted when the item is saved. Filling the list box is an operation that needs to take place in the Item_Open event handler on your form.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"John E." <je.lodestar[ at ]comcast.net> wrote in message news:3E202DDE-8951-4338-B0FF-EF1C915065EC[ at ]microsoft.com...
> Sue,
> The line... lstVisitRequests.List() = arrVisitRequests ....reads the array
> data into a list box that is resident in the form that is part of my VBA
> session and works fine. This is really there to test my read process and
> feed process to the list box.
> The line....m_objItem.lstVisitRequests = Join(arrVisitRequests, ",").....is
> what I am really trying to do, which is fill an identical lstVisitRequests
> list box in each objItem as they are being walked thru by the rest of the
> code within the For Each...EndIf loop. This list box has identical
> properties to the one in the test form referenced above, but resides on the
> 1st page of the custom form for each contact. Using the Watch feature I
> have confirmed that this For Each loop is working properly to walk thru each
> contact in the folder. My problem is I can't figure out how to get the
> arrVisitRequest data into the list box contained in each objItem list box.
>
> --
> John E.
>
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> If you already have this statement:
>>
>> lstVisitRequests.List() = arrVisitRequests
>>
>> I don't understand the purpose of this one:
>>
>> m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")

>> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:9BC4BDD5-5AE2-40B4-81D9-729051A5E277[ at ]microsoft.com...
>> >I have a custom form for Contacts that has a list box on the 1st page into
>> > which I am reading data from an Excel spreadsheet. Was trying to use the
>> > Join function to do this per pgs 108-109 of Sue's book but can't get past a
>> > run time error on the line that has comment relative to
>> > objItem.lstVisitRequest list box in below code. Can anyone advise me why
>> > this isn't working? Run time error given for this line is #5: Invalid
>> > procedure call or argument, yet it is done in same way as Sue's book.
>> > intRowCount = objRange.Rows.Count
>> > If intRowCount > 0 Then
>> > For Each m_objItem In m_objCurrentFolder.Items
>> > m_strCategories = m_objItem.Categories
>> > If InStr(m_strCategories, "International") > 0 Then
>> > lstVisitRequests.ColumnCount = 4
>> > Dim arrVisitRequests(ListBoxRows, 3)
>> > Dim arrList(ListBoxRows, 3)
>> > For I = 0 To intRowCount
>> > arrVisitRequests(I, 0) = objRange.Cells(I + 1, 1)
>> > arrVisitRequests(I, 1) = objRange.Cells(I + 1, 2)
>> > arrVisitRequests(I, 2) = objRange.Cells(I + 1, 3)
>> > arrVisitRequests(I, 3) = objRange.Cells(I + 1, 4)
>> > Next
>> > ' Fill the List Box from the loaded array.
>> > lstVisitRequests.List() = arrVisitRequests
>> > ' Fill the List Box in the current contact item
>> > m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
>> > ' above line has run time error
>> > m_objItem.Save
>> > End If
>> > Next
>> > End If
>> > --
>> > John E.
>>
Re: Filling listbox on custom Contact item 1st page
John E. 25.09.2006 23:38:01
Sue,
OK...I understand that the list box after being filled is not persistent
when the contact is saved and would have to be refilled each time the contact
is opened to see the intended content of the list-box.
But it appears to me that the Categories that are created in the Master
Category file and then checked by the user when setting up a contact ARE
persistent...both the category assigned and the check box are visible again
when the saved contact is re-opened. If I can't do what I want to do with a
list-box, is there a way I can replicate the Categories capability with code
and accomplish what I want to do via the establishment of categories?
--
John E.


"Sue Mosher [MVP-Outlook]" wrote:

[Quoted Text]
> >> fill an identical lstVisitRequests
> > list box in each objItem as they are being walked thru by the rest of the
> > code within the For Each...EndIf loop
>
> What you want to do is not possible. Changes to an item's UI -- such as filling a list box -- are not persisted when the item is saved. Filling the list box is an operation that needs to take place in the Item_Open event handler on your form.
> --
> Sue Mosher, Outlook MVP
> Author of Configuring Microsoft Outlook 2003
> http://www.turtleflock.com/olconfig/index.htm
> and Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:3E202DDE-8951-4338-B0FF-EF1C915065EC[ at ]microsoft.com...
> > Sue,
> > The line... lstVisitRequests.List() = arrVisitRequests ....reads the array
> > data into a list box that is resident in the form that is part of my VBA
> > session and works fine. This is really there to test my read process and
> > feed process to the list box.
> > The line....m_objItem.lstVisitRequests = Join(arrVisitRequests, ",").....is
> > what I am really trying to do, which is fill an identical lstVisitRequests
> > list box in each objItem as they are being walked thru by the rest of the
> > code within the For Each...EndIf loop. This list box has identical
> > properties to the one in the test form referenced above, but resides on the
> > 1st page of the custom form for each contact. Using the Watch feature I
> > have confirmed that this For Each loop is working properly to walk thru each
> > contact in the folder. My problem is I can't figure out how to get the
> > arrVisitRequest data into the list box contained in each objItem list box.
> >
> > --
> > John E.
> >
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> If you already have this statement:
> >>
> >> lstVisitRequests.List() = arrVisitRequests
> >>
> >> I don't understand the purpose of this one:
> >>
> >> m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
>
> >> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:9BC4BDD5-5AE2-40B4-81D9-729051A5E277[ at ]microsoft.com...
> >> >I have a custom form for Contacts that has a list box on the 1st page into
> >> > which I am reading data from an Excel spreadsheet. Was trying to use the
> >> > Join function to do this per pgs 108-109 of Sue's book but can't get past a
> >> > run time error on the line that has comment relative to
> >> > objItem.lstVisitRequest list box in below code. Can anyone advise me why
> >> > this isn't working? Run time error given for this line is #5: Invalid
> >> > procedure call or argument, yet it is done in same way as Sue's book.
> >> > intRowCount = objRange.Rows.Count
> >> > If intRowCount > 0 Then
> >> > For Each m_objItem In m_objCurrentFolder.Items
> >> > m_strCategories = m_objItem.Categories
> >> > If InStr(m_strCategories, "International") > 0 Then
> >> > lstVisitRequests.ColumnCount = 4
> >> > Dim arrVisitRequests(ListBoxRows, 3)
> >> > Dim arrList(ListBoxRows, 3)
> >> > For I = 0 To intRowCount
> >> > arrVisitRequests(I, 0) = objRange.Cells(I + 1, 1)
> >> > arrVisitRequests(I, 1) = objRange.Cells(I + 1, 2)
> >> > arrVisitRequests(I, 2) = objRange.Cells(I + 1, 3)
> >> > arrVisitRequests(I, 3) = objRange.Cells(I + 1, 4)
> >> > Next
> >> > ' Fill the List Box from the loaded array.
> >> > lstVisitRequests.List() = arrVisitRequests
> >> > ' Fill the List Box in the current contact item
> >> > m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
> >> > ' above line has run time error
> >> > m_objItem.Save
> >> > End If
> >> > Next
> >> > End If
> >> > --
> >> > John E.
> >>
>
Re: Filling listbox on custom Contact item 1st page
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 26.09.2006 00:33:43
It's not at all clear what you're trying to do other than fill a list box. Please fill us in on the bigger picture.

You can also write code behind your form to store the data needed to fill the list box so you can load it from the information in the form during the Item_Open event.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"John E." <je.lodestar[ at ]comcast.net> wrote in message news:3A9A713D-DF19-4E86-8C1F-07DC932BE752[ at ]microsoft.com...
[Quoted Text]
> Sue,
> OK...I understand that the list box after being filled is not persistent
> when the contact is saved and would have to be refilled each time the contact
> is opened to see the intended content of the list-box.
> But it appears to me that the Categories that are created in the Master
> Category file and then checked by the user when setting up a contact ARE
> persistent...both the category assigned and the check box are visible again
> when the saved contact is re-opened. If I can't do what I want to do with a
> list-box, is there a way I can replicate the Categories capability with code
> and accomplish what I want to do via the establishment of categories?
> --
> John E.
>
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> >> fill an identical lstVisitRequests
>> > list box in each objItem as they are being walked thru by the rest of the
>> > code within the For Each...EndIf loop
>>
>> What you want to do is not possible. Changes to an item's UI -- such as filling a list box -- are not persisted when the item is saved. Filling the list box is an operation that needs to take place in the Item_Open event handler on your form.
>>
>> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:3E202DDE-8951-4338-B0FF-EF1C915065EC[ at ]microsoft.com...
>> > Sue,
>> > The line... lstVisitRequests.List() = arrVisitRequests ....reads the array
>> > data into a list box that is resident in the form that is part of my VBA
>> > session and works fine. This is really there to test my read process and
>> > feed process to the list box.
>> > The line....m_objItem.lstVisitRequests = Join(arrVisitRequests, ",").....is
>> > what I am really trying to do, which is fill an identical lstVisitRequests
>> > list box in each objItem as they are being walked thru by the rest of the
>> > code within the For Each...EndIf loop. This list box has identical
>> > properties to the one in the test form referenced above, but resides on the
>> > 1st page of the custom form for each contact. Using the Watch feature I
>> > have confirmed that this For Each loop is working properly to walk thru each
>> > contact in the folder. My problem is I can't figure out how to get the
>> > arrVisitRequest data into the list box contained in each objItem list box.
>> >
>> > --
>> > John E.
>> >
>> >
>> > "Sue Mosher [MVP-Outlook]" wrote:
>> >
>> >> If you already have this statement:
>> >>
>> >> lstVisitRequests.List() = arrVisitRequests
>> >>
>> >> I don't understand the purpose of this one:
>> >>
>> >> m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
>>
>> >> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:9BC4BDD5-5AE2-40B4-81D9-729051A5E277[ at ]microsoft.com...
>> >> >I have a custom form for Contacts that has a list box on the 1st page into
>> >> > which I am reading data from an Excel spreadsheet. Was trying to use the
>> >> > Join function to do this per pgs 108-109 of Sue's book but can't get past a
>> >> > run time error on the line that has comment relative to
>> >> > objItem.lstVisitRequest list box in below code. Can anyone advise me why
>> >> > this isn't working? Run time error given for this line is #5: Invalid
>> >> > procedure call or argument, yet it is done in same way as Sue's book.
>> >> > intRowCount = objRange.Rows.Count
>> >> > If intRowCount > 0 Then
>> >> > For Each m_objItem In m_objCurrentFolder.Items
>> >> > m_strCategories = m_objItem.Categories
>> >> > If InStr(m_strCategories, "International") > 0 Then
>> >> > lstVisitRequests.ColumnCount = 4
>> >> > Dim arrVisitRequests(ListBoxRows, 3)
>> >> > Dim arrList(ListBoxRows, 3)
>> >> > For I = 0 To intRowCount
>> >> > arrVisitRequests(I, 0) = objRange.Cells(I + 1, 1)
>> >> > arrVisitRequests(I, 1) = objRange.Cells(I + 1, 2)
>> >> > arrVisitRequests(I, 2) = objRange.Cells(I + 1, 3)
>> >> > arrVisitRequests(I, 3) = objRange.Cells(I + 1, 4)
>> >> > Next
>> >> > ' Fill the List Box from the loaded array.
>> >> > lstVisitRequests.List() = arrVisitRequests
>> >> > ' Fill the List Box in the current contact item
>> >> > m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
>> >> > ' above line has run time error
>> >> > m_objItem.Save
>> >> > End If
>> >> > Next
>> >> > End If
>> >> > --
>> >> > John E.
>> >>
>>
Re: Filling listbox on custom Contact item 1st page
John E. 26.09.2006 23:24:02
Sue,
Finally succeeded in getting the VBA code converted to VBScript so it would
run with my custom form. Everything now works except for one thing, which
is a major shortcoming to the way we want it to work: as you point out, the
filled list box is not persistent and disappears when I save the contact and
attempt to re-open the saved item. I somehow need to resolve that with an
alternative approach that will be persistent.

I belive I understand what you are saying about putting code behind the form
to save the data that initally fills the list box to a separate file, and
then reading that file back in to the list box when the item is opened again.
However, I still want to always check the Excel file upon opening the item
for new data that wasn't in previous versions of the list box, and append any
new data to whatever was previously in the list box. Any suggestions?
--
John E.


"Sue Mosher [MVP-Outlook]" wrote:

[Quoted Text]
> It's not at all clear what you're trying to do other than fill a list box. Please fill us in on the bigger picture.
>
> You can also write code behind your form to store the data needed to fill the list box so you can load it from the information in the form during the Item_Open event.
> --
> Sue Mosher, Outlook MVP
> Author of Configuring Microsoft Outlook 2003
> http://www.turtleflock.com/olconfig/index.htm
> and Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:3A9A713D-DF19-4E86-8C1F-07DC932BE752[ at ]microsoft.com...
> > Sue,
> > OK...I understand that the list box after being filled is not persistent
> > when the contact is saved and would have to be refilled each time the contact
> > is opened to see the intended content of the list-box.
> > But it appears to me that the Categories that are created in the Master
> > Category file and then checked by the user when setting up a contact ARE
> > persistent...both the category assigned and the check box are visible again
> > when the saved contact is re-opened. If I can't do what I want to do with a
> > list-box, is there a way I can replicate the Categories capability with code
> > and accomplish what I want to do via the establishment of categories?
> > --
> > John E.
> >
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> >> fill an identical lstVisitRequests
> >> > list box in each objItem as they are being walked thru by the rest of the
> >> > code within the For Each...EndIf loop
> >>
> >> What you want to do is not possible. Changes to an item's UI -- such as filling a list box -- are not persisted when the item is saved. Filling the list box is an operation that needs to take place in the Item_Open event handler on your form.
> >>
> >> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:3E202DDE-8951-4338-B0FF-EF1C915065EC[ at ]microsoft.com...
> >> > Sue,
> >> > The line... lstVisitRequests.List() = arrVisitRequests ....reads the array
> >> > data into a list box that is resident in the form that is part of my VBA
> >> > session and works fine. This is really there to test my read process and
> >> > feed process to the list box.
> >> > The line....m_objItem.lstVisitRequests = Join(arrVisitRequests, ",").....is
> >> > what I am really trying to do, which is fill an identical lstVisitRequests
> >> > list box in each objItem as they are being walked thru by the rest of the
> >> > code within the For Each...EndIf loop. This list box has identical
> >> > properties to the one in the test form referenced above, but resides on the
> >> > 1st page of the custom form for each contact. Using the Watch feature I
> >> > have confirmed that this For Each loop is working properly to walk thru each
> >> > contact in the folder. My problem is I can't figure out how to get the
> >> > arrVisitRequest data into the list box contained in each objItem list box.
> >> >
> >> > --
> >> > John E.
> >> >
> >> >
> >> > "Sue Mosher [MVP-Outlook]" wrote:
> >> >
> >> >> If you already have this statement:
> >> >>
> >> >> lstVisitRequests.List() = arrVisitRequests
> >> >>
> >> >> I don't understand the purpose of this one:
> >> >>
> >> >> m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
> >>
> >> >> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:9BC4BDD5-5AE2-40B4-81D9-729051A5E277[ at ]microsoft.com...
> >> >> >I have a custom form for Contacts that has a list box on the 1st page into
> >> >> > which I am reading data from an Excel spreadsheet. Was trying to use the
> >> >> > Join function to do this per pgs 108-109 of Sue's book but can't get past a
> >> >> > run time error on the line that has comment relative to
> >> >> > objItem.lstVisitRequest list box in below code. Can anyone advise me why
> >> >> > this isn't working? Run time error given for this line is #5: Invalid
> >> >> > procedure call or argument, yet it is done in same way as Sue's book.
> >> >> > intRowCount = objRange.Rows.Count
> >> >> > If intRowCount > 0 Then
> >> >> > For Each m_objItem In m_objCurrentFolder.Items
> >> >> > m_strCategories = m_objItem.Categories
> >> >> > If InStr(m_strCategories, "International") > 0 Then
> >> >> > lstVisitRequests.ColumnCount = 4
> >> >> > Dim arrVisitRequests(ListBoxRows, 3)
> >> >> > Dim arrList(ListBoxRows, 3)
> >> >> > For I = 0 To intRowCount
> >> >> > arrVisitRequests(I, 0) = objRange.Cells(I + 1, 1)
> >> >> > arrVisitRequests(I, 1) = objRange.Cells(I + 1, 2)
> >> >> > arrVisitRequests(I, 2) = objRange.Cells(I + 1, 3)
> >> >> > arrVisitRequests(I, 3) = objRange.Cells(I + 1, 4)
> >> >> > Next
> >> >> > ' Fill the List Box from the loaded array.
> >> >> > lstVisitRequests.List() = arrVisitRequests
> >> >> > ' Fill the List Box in the current contact item
> >> >> > m_objItem.lstVisitRequests = Join(arrVisitRequests, ",")
> >> >> > ' above line has run time error
> >> >> > m_objItem.Save
> >> >> > End If
> >> >> > Next
> >> >> > End If
> >> >> > --
> >> >> > John E.
> >> >>
> >>
>
Re: Filling listbox on custom Contact item 1st page
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 27.09.2006 01:30:46
If you're going to check the Excel file every time, why not just use it to fill the list box every time?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"John E." <je.lodestar[ at ]comcast.net> wrote in message news:E0153E33-FE6E-4B14-A74B-4829B7AFC37A[ at ]microsoft.com...
[Quoted Text]
> Sue,
> Finally succeeded in getting the VBA code converted to VBScript so it would
> run with my custom form. Everything now works except for one thing, which
> is a major shortcoming to the way we want it to work: as you point out, the
> filled list box is not persistent and disappears when I save the contact and
> attempt to re-open the saved item. I somehow need to resolve that with an
> alternative approach that will be persistent.
>
> I belive I understand what you are saying about putting code behind the form
> to save the data that initally fills the list box to a separate file, and
> then reading that file back in to the list box when the item is opened again.
> However, I still want to always check the Excel file upon opening the item
> for new data that wasn't in previous versions of the list box, and append any
> new data to whatever was previously in the list box. Any suggestions?

Re: Filling listbox on custom Contact item 1st page
John E. 27.09.2006 04:36:02
Here is why. In our application, at time of initiating a new contact with
the custom form, the list box will be filled and the user will then select
one or more of the check boxes while completing the data in the contact form.
These check box selections need to be preserved after the new contact is
then saved and re-opened the next time. At the next time of opening of the
same contact, I need to read the data back into the list box, but those rows
that were selected in the option check boxes previously need to be reinstated
automatically without the user having to re-check the boxes. Which check
boxes are selected from the total list at time of contact initializaion and
initial list box fill will vary from contact to contact.
I thought about using some code triggered by the Write event in which the
Selected property of the list box would determine in a loop which rows in the
list box were selected and then store this as an array somehow so it could be
used on the next Open event of this specific contact to re-establish which
rows of the new fill need to be re-selected. I think this could be
accomplished, but I am struggling with how to implement it.
--
John E.


"Sue Mosher [MVP-Outlook]" wrote:

[Quoted Text]
> If you're going to check the Excel file every time, why not just use it to fill the list box every time?
>
> --
> Sue Mosher, Outlook MVP
> Author of Configuring Microsoft Outlook 2003
> http://www.turtleflock.com/olconfig/index.htm
> and Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
> "John E." <je.lodestar[ at ]comcast.net> wrote in message news:E0153E33-FE6E-4B14-A74B-4829B7AFC37A[ at ]microsoft.com...
> > Sue,
> > Finally succeeded in getting the VBA code converted to VBScript so it would
> > run with my custom form. Everything now works except for one thing, which
> > is a major shortcoming to the way we want it to work: as you point out, the
> > filled list box is not persistent and disappears when I save the contact and
> > attempt to re-open the saved item. I somehow need to resolve that with an
> > alternative approach that will be persistent.
> >
> > I belive I understand what you are saying about putting code behind the form
> > to save the data that initally fills the list box to a separate file, and
> > then reading that file back in to the list box when the item is opened again.
> > However, I still want to always check the Excel file upon opening the item
> > for new data that wasn't in previous versions of the list box, and append any
> > new data to whatever was previously in the list box. Any suggestions?
>
>
Re: Filling listbox on custom Contact item 1st page
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 27.09.2006 11:59:40
The user's selections are data that should be stored in the Outlook item. Your "thought about using some code" is exactly on target. My sample form at http://www.outlookcode.com/files/FormControlsDemo.zip has an example of how to do this.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"John E." <je.lodestar[ at ]comcast.net> wrote in message news:1A0F3508-7878-4B43-BEEB-206D1817C063[ at ]microsoft.com...
[Quoted Text]
> Here is why. In our application, at time of initiating a new contact with
> the custom form, the list box will be filled and the user will then select
> one or more of the check boxes while completing the data in the contact form.
> These check box selections need to be preserved after the new contact is
> then saved and re-opened the next time. At the next time of opening of the
> same contact, I need to read the data back into the list box, but those rows
> that were selected in the option check boxes previously need to be reinstated
> automatically without the user having to re-check the boxes. Which check
> boxes are selected from the total list at time of contact initializaion and
> initial list box fill will vary from contact to contact.
> I thought about using some code triggered by the Write event in which the
> Selected property of the list box would determine in a loop which rows in the
> list box were selected and then store this as an array somehow so it could be
> used on the next Open event of this specific contact to re-establish which
> rows of the new fill need to be re-selected. I think this could be
> accomplished, but I am struggling with how to implement it.

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net