Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a script from code

Status
Not open for further replies.

staleb

Programmer
Feb 7, 2005
45
NO
Hi
Hope this is the right forum for this
This is my scenario:

The user decides what kind of document he wants to create.

The document is created by the application and stored on the server.
Since I dont know how to store the document directly on to the clients machine, I'm storing it on the server.
Now comes the tricky part:

In order to open the document I normally use a vb script.
But since I want to open the document in my code and store it locally at the users computer.
I have been trying with this code

Private Sub Document
< code for creating the document and storing it on the server >

Dim script As String
script = "<script language=""vbscript"">" & vbCrLf
script &= " Dim Word" & vbCrLf
script &= " Dim Doc" & vbCrLf
script &= " Sub VisDok() " & vbCrLf
script &= " Set Word = CreateObject(""Word.Application"") " & vbCrLf
script &= " Set Doc = CreateObject(""Word.Document"") " & vbCrLf
script &= " Word.Visible = True" & vbCrLf
'script &= " Doc = Word.Documents.Open('" & sDokNavn & "')" & vbCrLf
script &= " Set Doc = Word.Documents.Open("" \\server\Dokument\2005\fp64486.doc "")" & vbCrLf
script &= " Doc.SaveAs(""c:\test.doc"")" & vbCrLf
script &= " End Sub" & vbCrLf
script &= "</script>" & vbCrLf
Me.Page.RegisterStartupScript("Open", script)

End Sub


Am I way off here or can somthing like this be done?


The reason why I'm trying to do it this way is this.
When the document is first created, its path(on the server) is stored in the db.
But if opening and storing the document is succesfull, I want to store the loacal path in the db.
So that the user can open the document thats stored locally later.

Hope this wasnt to confusing?
I know the script works fine as a normal script in the html-code, but when I try it in my vb.net code somthing is wrong!



 
is the script outputted???

Known is handfull, Unknown is worldfull
 
What do u mean with outputed?

If u mean that I can go to "view source" in the explorer and see it, then yes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top