Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Problems with ASP and MS WORD

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,3063
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Problems with ASP and MS WORD
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Problems with ASP and MS WORD - 5/19/2005 4:23:58 PM   
  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'!!!!
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Problems with ASP and MS WORD Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts