Hello:
I'm trying to populate a grid control Using VBscript
Set Controls = Item.GetInspector.ModifiedFormPages("Grid Test Page").Controls
Set ctrlGrid = Controls("DataGrid1")
ctrlGrid.Col = 1
ctrlGrid.Row = 1
ctrlGrid(1,1).value = "Field Value"
But line ctrlGrid.Col = 1 causes the "Rowset not available" error.
What's wrong here?
On another note the Outlook can't find the DataSource property when I'm trying to bind a grid
to ADO recordset:
ctrlGrid.DataSource = rs
Is that because the DataSource property is greyed out on the grid's property list?
Please advice. Where else if not here?
Ken Slovak - [MVP - Outlook] - 12 Jan 2004 15:05 GMT
You can't use a bound recordset in a grid control in an Outlook form.
You have to populate the grid directly from the recordset in your code
using something like AddItem depending on the grid you are using.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginners Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> Hello:
>
[quoted text clipped - 15 lines]
>
> Please advice. Where else if not here?
ablei2000 - 12 Jan 2004 23:36 GMT
Thank very much, Ke
But I can't find the way to populate the grid even without direct binding.
The example I gave in my first email doesn't work. Coudl you give me an example
Thank you.
Ken Slovak - [MVP - Outlook] - 13 Jan 2004 14:23 GMT
Assuming you have something like an ADO recordset that has all the
data you want in the grid you would iterate that recordset and get
field data into a string with each field separated by a Tab character
and then use the AddItem method of the gird to add a new row.
Something like this:
Sub PopulateGrid(oGrid, oRecordSet)
Dim strRow
If oRecordSet.State = 1 Then 'open
oRecordSet.MoveFirst
Do While Not oRecordSet.EOF
strRow = oRecordSet.Fields("FirstField")
strRow = strRow & vbTab & oRecordSet.Fields("NextField")
'and so on adding fields
oGrid.AddItem strRow
oRecordSet.MoveNext
Loop
End If
End Sub
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginners Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> Thank very much, Ken
>
> But I can't find the way to populate the grid even without direct binding.
> The example I gave in my first email doesn't work. Coudl you give me an example.
>
> Thank you.
ablei2000 - 14 Jan 2004 05:56 GMT
Great! Thanks Ken. That works for Microsoft FlexGrid.
Simple Microsoft grid does not have addItem method, and I do not see any replacement.
I'm not smart enough to use vbTab to populate each sell individually.
How can contribute to you MVP status to make it TMVP - The Most Valuable :)
P.S You also anwered on my question about COM add-in vs ActiveX.
Sorry to be enjoying but is there a way to call a VBA macro from Vbscript in Outlook?
Ken Slovak - [MVP - Outlook] - 14 Jan 2004 15:05 GMT
I'm not sure what grid you mean. The grids that are available in
Visual Studio or Office Developer would be the MS FlexGrid or the
HFlexGrid. If you mean some other grid it must have a method that
allows adding rows to it. You would have to use the Object Browser or
Help for that grid control to see what methods are available for your
use.
Using vbTab to separate columns in a row in the grid works for the 2
grid controls I mentioned. What would be used in another grid would
depend on the grid. It's not hard to get each field you are interested
in from the current record in a recordset and concatenate each field
separated by vbTab characters. It's just repetitive code in a loop.
You can call a VBA procedure from form code but it's not supported
officially and may not be doable in later versions of Outlook. See
http://support.microsoft.com/?kbid=221827 for information on how to
call a VBA procedure from VBScript in a form.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginners Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> Great! Thanks Ken. That works for Microsoft FlexGrid.
> Simple Microsoft grid does not have addItem method, and I do not see any replacement.
[quoted text clipped - 5 lines]
>
> Sorry to be enjoying but is there a way to call a VBA macro from Vbscript in Outlook?