| |
aksh2rule
Posts: 10
Score: 0
Joined: 5/18/2005
From:
Status: offline
|
I am trying to create a merge kind of a thing with asp and vbscript vbscript runs word on the client asp retrieves fields from the database for merging Here's the current code: <% set conn=CreateObject("ADODB.connection") conn.Open "DRIVER={SQL Server};Server=blrkec19392;uid=sa;pwd=sa;database=ctydb" set rs=CreateObject("ADODB.recordset") 'rs holds all database fields rs.Open conn.Execute("SELECT School,Address FROM AdLetSch WHERE dc='Bangalore' and yr='2005'") %> <script language=vbscript> <!-- sub mergeall() dim arr(14)'Holds current fields arr(1)=frmInput.elements(0).value for i=4 to 10 arr(i)=frmInput.elements(i-3).value next arr(11)=arr(8) for i=12 to 14 arr(i)=frmInput.elements(i-4).value next set WApp=CreateObject("Word.Application") WApp.visible=true set Template=WApp.Documents.Open(frmInput.fpath.value) set NewFil=WApp.Documents.Add() set Temp=WApp.Documents.Add() While not rs.EOF Template.Select WApp.Selection.Copy() Temp.Select WApp.Selection.Paste() Temp.Select For i=1 to 14 WApp.Selection.ClearFormatting() WApp.Selection.Find.Text="["&i&"]" WApp.Selection.Find.Execute() if i=2 then WApp.Selection=<%=rs("School")%> elseif i=3 then WApp.Selection=<%=rs("Address")%> else WApp.Selection=arr(i) end if Temp.Select Next Temp.Select NewFil.Content.InsertAfter(WApp.Selection) NewFil.Content.InsertAfter(vbFormFeed) rs.MoveNext Wend rs.MoveFirst Temp.Close(false) Template.Close(false) WApp.visible=true end sub --> </script> The interesting thing is that it will work on my comp (my comp is the server too) if i save the file with a .html extension and put the asp script in my vbscript client side script Word does not open. What is wrong! Help !
_____________________________
To catch me, ya gotta be fast, to find me, ya gotta be smart; but to be me? D*mn! You must be kiddin'!!!!
|
|