Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/06/2004, 18:39
Avatar de Atonovich
Atonovich
 
Fecha de Ingreso: diciembre-2002
Ubicación: ...
Mensajes: 117
Antigüedad: 22 años, 5 meses
Puntos: 0
Uuuuuuuuy! pues para empezar tendrìas que saber como crear objetos Word en una pàgina asp....
Despùes interactuar con el modelo de objetos de Word... es sencillo pero talachudo...
Aquì hay una manera no muy elegante (es mi opiniòn) de hacerlo pero si tu cliente no tiene office 97 instalado con el convertidor a HTML cuando accese a tus reportes verà...solo HTML..

http://www.infinetsoftware.com/conte...edocuments.asp

Hay otra manera que es muuuuy talachuda y como le digo yo, de "campeones" que es ponerse a estudiar la sintaxis de la creaciòn de documentos RTF y por medio del FSO de ASP crear un RTF "on the fly" checa esta belleza:

<%@ Language=VBScript %>
<%
Dim sRTF, sConn
sConn = "c:\program files\microsoft office\office\samples\northwind.mdb"

Response.Buffer = True

'Create the file for the RTF
Dim fso, MyFile, sFileName
Set fso = CreateObject("Scripting.FileSystemObject")
sFileName = "sample2.doc"
Set MyFile = fso.CreateTextFile(Server.MapPath(".") & "\" & _
sFileName, True)

MyFile.WriteLine("{\rtf1")

'Write the font table
sRTF = "{\fonttbl {\f0\froman\fcharset0 Times New Roman;}" & _
"{\f1\fswiss\fcharset0 Arial;}" & _
"{\f2\fmodern\fcharset0 Courier New;}}"
MyFile.WriteLine sRTF

'Write the title and author for the document properties
MyFile.WriteLine("{\info{\title Sample RTF Document}" & _
"{\author Microsoft Developer Support}}")

'Write the document header and footer
MyFile.WriteLine("{\header\pard\qc\brdrb\brdrs\brd rw10\brsp100" & _
"{\fs50 Northwind Traders} \par}")
MyFile.WriteLine("{\footer\pard\qc\brdrt\brdrs\brd rw10\brsp100" & _
"{\fs18 Questions?\par Call (111)-222-3333, " & _
" Monday-Friday between 8:00 am and 5:00 pm} \par}")

'Connect to the database in read-only mode
Dim conn, rs
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Mode = 1 'adModeRead=1
conn.Open sConn

'Execute a query that returns ID, Product name and amount of sale
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT Orders.ShippedDate, Orders.ShipVia, " & _
"Orders.OrderDate, Orders.OrderID, " & _
"Customers.ContactName FROM Customers INNER JOIN Orders ON " & _
"Customers.CustomerID = " & _
"Orders.CustomerID WHERE (((Orders.ShippedDate) Between " & _
"#1/1/1998# And #3/31/98#))",conn,3 'adOpenStatic = 3

Do While Not (rs.eof)

'Write the "body" of the form letter

MyFile.WriteLine "\fs26\f1" 'Default font

MyFile.WriteLine "\pard"
MyFile.WriteLine "\par\par\par\par"
MyFile.WriteLine "\par RE: Order #" & rs.Fields("OrderID").Value
MyFile.WriteLine "\par"
MyFile.WriteLine "\par"
MyFile.WriteLine "\par " & rs.Fields("ContactName").Value & ", "
MyFile.WriteLine "\par"
MyFile.WriteLine "\par Thank you for your order on " & _
rs.Fields("ShippedDate").Value & _
". Your order has been shipped: "
MyFile.WriteLine "\par"
MyFile.WriteLine "\par"

MyFile.WriteLine "\pard \li720 {\f2"
MyFile.WriteLine "\par \b Order Number \b0 \tab " & _
rs.Fields("OrderID").Value
MyFile.WriteLine "\par \b Shipped By \b0 \tab " & _
rs.Fields("ShipVia").Value
MyFile.WriteLine "\par \b Shipped On \b0 \tab " & _
rs.Fields("ShippedDate").Value
MyFile.WriteLine "\par}"

MyFile.WriteLine "\pard"
MyFile.WriteLine "\par"
MyFile.WriteLine "\par Northwind Traders is committed to " & _
"bringing you products of the " & _
"highest quality from all over the world. If " & _
"at any time you are not completely satisfied " & _
"with any of our products, you may " & _
"return them to us for a full refund."
MyFile.WriteLine "\par"

MyFile.WriteLine "\pard {\fs18 \qc \i"
MyFile.WriteLine "\par Thank you for choosing Northwind Traders!"
MyFile.WriteLine "\par}"

rs.MoveNext

'Add a page break and then a new paragraph
If Not(rs.eof) Then MyFile.WriteLine("\pard \page")

Loop

'Close the recordset and database
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing

'close the RTF string and file
MyFile.WriteLine("}")
MyFile.Close

Response.Write _
"<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=" & sFileName & """>"

%>


Te comento que la siguiente opciòn me gusta más por la libertad que tienes de manejar el modelo de objetos de word

<%
Dim wrdApp

Set wrdApp = Server.CreateObject("Word.Application")

wrdApp.Documents.Add
wrdApp.ActiveDocument.Content.InsertFile ("c:\test.doc")
wrdApp.ActiveDocument.Content.InsertParagraphBefor e
wrdApp.ActiveDocument.Content.InsertBefore "Application No." & 1234
wrdApp.ActiveDocument.SaveAs "1234.doc", , , , , , 1

set wrdApp = nothing

%>


Probablemente si eliges esta opción te encontrarás con el problema de "Access Denied" o algo asì, o "No se peude abrir el almacenamiento de macros" en tal caso ejecuta "DCOMCNFG", selecciona la aplicaciòn "Hoja de Word" (o algo asì) y en la pestaña de usuarios o accesibilidad otorgas ejecuciòn de "usuario interactivo"

Ojalà esta info te sea de valor

Saludos
__________________
" El hombre es una invención de Dios o Dios es una invención del hombre..."