New error: Microsoft VBScript runtime error: Object doesn't support this property or method: 'document.forms(...).Item.
In your solution, where do identify DataGrid1?
Main Topics
Browse All TopicsI have created aweb application in ASP.NET 2.0 with VB.NET (VS2005) and SQL Server 2005. I have Word 2003 templates that must be filled through automation on the client-side (VBScript) - each user's location has indvidualized templates. I was hoping to be able to fill the Word doc from either a datagrid or gridview which is made up of a single row. I have a button on the page with the datagrid/gridview that triggers the VBScript, opening the bookmarked Word template. My probem is how do I read each cell from the datagrid/gridview.
The relevant code for a DataGrid is:
<form id="form1" runat="server">
<div>
<asp:datagrid id="DataGrid1" runat="server" GridLines="Vertical" CellPadding="3" BackColor="White"
BorderColor="#999999" BorderWidth="1px" BorderStyle="None" Width="100%" Height="100%" Font-Size="X-Small"
Font-Names="Verdana">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></Sele
<AlternatingItemStyle BackColor="Gainsboro"></Al
<ItemStyle BorderWidth="2px" ForeColor="Black" BorderStyle="Solid" BorderColor="Black" BackColor="#EEEEEE"></Item
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" BorderWidth="2px" ForeColor="White" BorderStyle="Solid"
BorderColor="Black" BackColor="#000084"></Head
<FooterStyle ForeColor="Black" BackColor="#CCCCCC"></Foot
<PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></Page
</asp:datagrid>
<asp:TextBox ID="WPAID" runat="server" Text="-1391708654"></asp:T
<asp:Button id="Button1" usesubmitbehavior="true" Text="Print WPA" OnClientClick="FillWPA()" runat="server" />
</div>
</form>
<script type="text/vbscript">
function FillWPA()
Dim oWord, oDoc, oConn, sCommand, sReader, oGridItem
Set oWord = CreateObject("Word.Applica
Set oDoc = oWord.Documents.Open("C:\N
oWord.Visible = true
oDoc.FormFields("Date").re
oDoc.FormFields("Geo").res
oDoc.FormFields("Adm").res
.
.
.
oDoc.FormFields("Edu").res
oDoc.SaveAs "C:\NM_Works\Documents\WPA
I get an error: Microsoft VBScript runtime error: Object required: 'document.form1(...)'
end function
</script>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Dim oDataGrid
oDataGrid = document.getElementById("<
'Now you have instance of Table that DataGrid produces on the client side in variable oDataGrid
'You could use
FirstCellInFirstRow = oDataGrid.rows(0).cells(0)
and so on. Keep in mind that depending upon the ItemTemplate you may have to go even deeper in cell to get exact value. Although I see that you probably are not using any.
Business Accounts
Answer for Membership
by: aki4uPosted on 2007-07-21 at 04:20:02ID: 19538100
try using document.forms(0) instead of document.form1