SoloCodigo

Programación General => Visual Basic 6.0 e inferiores => Visual Basic para principiantes => Mensaje iniciado por: gajajil en Jueves 19 de Junio de 2008, 01:50

Título: Visual Basic, Access Y Word
Publicado por: gajajil en Jueves 19 de Junio de 2008, 01:50
Desde Visual Basic 6 quiero abrir documento word y vaciar datos de base de datos access 97, puedo abrir el documento desde VB pero no encuentro como agregar informaciín de la base de datos al documento word, gracias por su apoyo.
Título: Re: Visual Basic, Access Y Word
Publicado por: cris17 en Sábado 28 de Junio de 2008, 21:40
YO TB NECESITO ESO, SI LO ENCUENTRAS ME AVISAS,
CHAOOOO :D
Título: Re: Visual Basic, Access Y Word
Publicado por: F_Tanori en Lunes 30 de Junio de 2008, 07:59
Esto se puede resolver con , combinacion de correspondencia en Word
http://support.microsoft.com/kb/258512 (http://support.microsoft.com/kb/258512" onclick="window.open(this.href);return false;)

o puedes crear una plantilla en Word y crearle "marcadores" para modificarlos desde VB aqui un ejemplo con VBA
pero funciona igual con VB agregando las referencias correspondientes

http://www.ajpdsoft.com/modules.php?nam ... le&sid=251 (http://www.ajpdsoft.com/modules.php?name=News&file=article&sid=251" onclick="window.open(this.href);return false;)


De igual forma se puede usar los metodos Find y Replace creando una instancia de Word.application
http://www.vbforums.com/archive/index.php/t-386366.html (http://www.vbforums.com/archive/index.php/t-386366.html" onclick="window.open(this.href);return false;)


Saludos
Título: Re: Visual Basic, Access Y Word
Publicado por: cris17 en Viernes 4 de Julio de 2008, 04:32
a ver si esto te ayuda.
Private Sub cmdguardar_Click()
'guarda el documento como word
Dim MSWord As New Word.Application
Dim Documento As Word.Document
Dim Parrafo As Paragraph
Set Documento = MSWord.Documents.Add
Set Parrafo = Documento.Paragraphs.Add

'envia a word lo que haya en el text
Parrafo.Range.InsertAfter txtdetalle.Item(I).Text & vbCrLf & vbCrLf
Parrafo.Range.InsertAfter txtcontenido.Text & vbCrLf & vbCrLf
Parrafo.Range.InsertAfter txtfechat.Text & vbCrLf & vbCrLf
Parrafo.Range.InsertAfter Text5.Text
Parrafo.Range.InsertAfter txtfecha.Text & vbCrLf & vbCrLf
Parrafo.Range.InsertAfter Text4.Text
Parrafo.Range.InsertAfter txtnombrec.Text & vbCrLf & vbCrLf
Parrafo.Range.InsertAfter Text3.Text
Parrafo.Range.InsertAfter txtdescripcion.Text & vbCrLf & vbCrLf
Parrafo.Range.InsertAfter Text2.Text
Parrafo.Range.InsertAfter txtnumero.Text & vbCrLf & vbCrLf
Parrafo.Range.InsertAfter Text1.Text
Parrafo.Range.InsertAfter txttitulo.Text & vbCrLf & vbCrLf
MSWord.Selection.Font.Name = "Arial"
MSWord.Selection.Paragraphs.Alignment = wdAlignParagraphJustify
MSWord.Selection.Font.Bold = True

MSWord.Visible = True
end sub