Open a Word Document in Browser IE5 using ASP

Results 1 to 3 of 3

Thread: Open a Word Document in Browser IE5 using ASP

  1. #1
    Joe Contreras Guest

    Default Open a Word Document in Browser IE5 using ASP

    Hi I&#039m trying to generate a Word document using parameters from an ASP/HTML form and have that Word document be open in the IE5 browser.<BR><BR>I&#039ve been testing this sample code:<BR><BR>Dim MyDoc<BR>Set MyDoc = CreateObject("Word.Document")<BR>MyDoc.Application .Visible = True<BR>MyDoc.content.Font.Bold = True<BR>MyDoc.content.Font.Italic = True<BR>MyDoc.content.Font.Underline = True<BR>MyDoc.content.Font.Name = "Comic Sans MS"<BR>MyDoc.content.Font.Size = 25<BR>MyDoc.content.insertAfter "word1 word2 word3 word4"<BR>MyDoc.content.InsertParagraphAfter<BR>My Doc.Words(1).Font.Size = 10<BR>MyDoc.Words(1).Font.ColorIndex = 1<BR>MyDoc.Words(2).Font.Size = 20<BR>MyDoc.Words(2).Font.ColorIndex = 2<BR>MyDoc.Words(3).Font.Size = 30<BR>MyDoc.Words(3).Font.ColorIndex = 3<BR>MyDoc.Words(4).Font.Size = 40<BR>MyDoc.Words(4).Font.ColorIndex = 4<BR>&#039MyDoc.PrintOut<BR>Set MyDoc = Nothing<BR><BR>but all I see in the browser is a white page.<BR><BR>Help would be appreciated it.<BR><BR>Thanks

  2. #2
    Michael Swanson Guest

    Default RE: Open a Word Document in Browser IE5 using ASP

    This appears to create an instance of the Word object ON THE SERVER. As such, you are creating a document, populating and formatting it, then discarding it. The client never sees anything, because it isn&#039t being sent anything.<BR><BR>Michael Swanson, MCSE, MCP+Internet<BR>Webmaster<BR>Donnelly Corporation<BR>

  3. #3
    Raj Chilka Guest

    Default RE: Open a Word Document in Browser IE5 using ASP

    Try this code I used similar code to open asp data in Excel.It works for me <BR>---------------------------<BR>&#060;BODY&#062;<BR>&#060;%<BR>nRandom = Int((1000000 - 1 + 1) * Rnd + 1000000)<BR>fileExcel = "t" & Cstr(nRandom) & ".doc"<BR>filename = "C:\" & "\" & fileExcel <BR><BR>Set fs = CreateObject("Scripting.FileSystemObject")<BR>Set Myfile = fs.CreateTextFile(filename, True)<BR>*****True will overwrite excel file if it already exists*******<BR><BR>Set objConn=server.CreateObject("ADODB.Connection") <BR>objConn.Open "DRIVER={SQL Server};SERVER=servername;UID=userID;PWD=password; DATABASE=Databasename" <BR>Set objRec = objConn.Execute("select * from table1 where db_cd in (&#039a&#039,&#039b&#039)")<BR>strLine = ""<BR>For each X in objrec.Fields<BR>strLine = strLine & UCase( & chr(9) <BR>Next<BR>MyFile.Writeline strLine <BR><BR>Do while Not objRec.EOF<BR> strLine = ""<BR>For each X in objRec.Fields<BR> strLine = strLine & X.value & chr(9)<BR>next<BR> MyFile.Writeline strLine <BR> objRec.MoveNext<BR>Loop<BR><BR>Link = "&#060;A HREF= C:\" & "\" & fileExcel & "&#062;Open Excel&#060;/A&#062;"<BR>Response.Write Link<BR><BR>%&#062;<BR>&#060;/BODY&#062;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts