staleb
asked on
Fire vb-script from code, Syntax-error
I'm getting a Syntax error in the Internet explorer when I'm trying to fire a vb script from code.
I have coppied the script from an old vb-project, but I must be translating it wrong.
Can anyone help me?
StringBuilder sb = new StringBuilder("");
sb.Append("\n<script language=vbscript >\n");
sb.Append(" Dim Word \n");
sb.Append(" Dim Doc \n");
sb.Append("Set Word = CreateObject(\"Word.Applic ation\")\n ");
sb.Append("Set Doc = CreateObject(\"Word.Docume nt\")\n ");
sb.Append("Word.Visible = True \n");
sb.Append("Set Doc = Word.Documents.Open(\"");
sb.Append(fileName.ToStrin g());
sb.Append(" \")\n ");
sb.Append("Doc.SaveAs(\"") ;
sb.Append(fileNameLocal);
sb.Append("\")\n");
sb.Append("</script> \n");
this.Page.RegisterStartupS cript("Ope n", sb.ToString());
I have coppied the script from an old vb-project, but I must be translating it wrong.
Can anyone help me?
StringBuilder sb = new StringBuilder("");
sb.Append("\n<script language=vbscript >\n");
sb.Append(" Dim Word \n");
sb.Append(" Dim Doc \n");
sb.Append("Set Word = CreateObject(\"Word.Applic
sb.Append("Set Doc = CreateObject(\"Word.Docume
sb.Append("Word.Visible = True \n");
sb.Append("Set Doc = Word.Documents.Open(\"");
sb.Append(fileName.ToStrin
sb.Append(" \")\n ");
sb.Append("Doc.SaveAs(\"")
sb.Append(fileNameLocal);
sb.Append("\")\n");
sb.Append("</script> \n");
this.Page.RegisterStartupS
ASKER
I'm not sure thisis the solution
Since this is a web application, And I don't want the users to use Wordl server-side. But I want them to use their local MSWord so that they can edit the document.
If I use a document stored server-side, it will come up write-protected
Since this is a web application, And I don't want the users to use Wordl server-side. But I want them to use their local MSWord so that they can edit the document.
If I use a document stored server-side, it will come up write-protected
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is the script I'm trying to "translate"
script = "<script language=""vbscript"">" & vbCrLf
script &= " Dim Word" & vbCrLf
script &= " Dim Doc" & vbCrLf
script &= " Set Word = CreateObject(""Word.Applic ation"") " & vbCrLf
script &= " Set Doc = CreateObject(""Word.Docume nt"") " & vbCrLf
script &= " Word.Visible = True" & vbCrLf
script &= " set Doc = Word.Documents.Open(""" & sDokNavn.ToString & """) " & vbCrLf
script &= " Doc.SaveAs(""" & sDokNavnLokalt & """)" & vbCrLf
script &= "</script>" & vbCrLf
script = "<script language=""vbscript"">" & vbCrLf
script &= " Dim Word" & vbCrLf
script &= " Dim Doc" & vbCrLf
script &= " Set Word = CreateObject(""Word.Applic
script &= " Set Doc = CreateObject(""Word.Docume
script &= " Word.Visible = True" & vbCrLf
script &= " set Doc = Word.Documents.Open(""" & sDokNavn.ToString & """) " & vbCrLf
script &= " Doc.SaveAs(""" & sDokNavnLokalt & """)" & vbCrLf
script &= "</script>" & vbCrLf
ASKER
Finally Made it work
Added + Environment.NewLine and altered some security settings in the browser and it worked.
Not quite sure what was the trigger that made it work, but it does work so.. :)
Added + Environment.NewLine and altered some security settings in the browser and it worked.
Not quite sure what was the trigger that made it work, but it does work so.. :)
Microsoft Word Documents from ASP.NET
http://www.codeproject.com/aspnet/wordapplication.asp
Bob