Discussion:
Leer campos de Word desde Access
(demasiado antiguo para responder)
Batrrena
2007-01-18 20:56:25 UTC
Hola:

Se me plantea la necesidad de leer el contenido de unos campos contenidos en
un documento de Word desde Access. Se trataría de elegir un documento Word
que estuviese en una carpeta y grabar el texto que haya en los campos en una
tabla.

A ver si alguien me puede iluminar un poco el camino

Gracias por anticipado
josé Mª Fueyo
2007-01-19 12:20:17 UTC
Hola
Me imagino que te refieres a marcadores insertados en un documento de Word
¿no? bien. No nos comentas que versión de Office usas. Esto que he
encontrado está aplicado a Office XP, no es exactamente lo que quieres pero
creo que te pude dar pistas

<pego>
Finding a Bookmark in an Embedded Microsoft Word Document
By using Automation code in Microsoft Access, you can open a Microsoft Word
document and move to a bookmark location in the document.

The following example opens a document that is embedded in a Microsoft
Access form.

This example assumes that you have Microsoft Word set up on your computer,
that you have a document called C:\My Documents\WordTest.doc, and that the
document contains a pre-defined bookmark called City.

1.. Open the sample database Northwind.mdb.
2.. Open any module in Design view.
3.. On the Tools menu, click References.
4.. In the Available References list, click to select the Microsoft Word
10 Object Library check box. If this option doesn't appear in the list,
click Browse, locate the Msword.olb file, which is installed in the
C:\Program Files\Microsoft Office\Office10 folder by default, and click
Open.
5.. In the References dialog box, click OK.
6.. Create a new form that is not based on any table or query in Design
view.
7.. Add an unbound object frame control to the detail section of the form.
8.. When the Insert Object dialog box appears, click Create From File,
click Browse, select the C:\My Documents\WordTest.doc file and then click
Open.
9.. Click OK.
10.. Set the following properties for the unbound object frame control:
Unbound Object Frame
Name: UnboundObj
Locked: No
11.. Add a command button to the form; set its Name property to
EditWordDoc and set its OnClick property to the following event procedure:
Private Sub

EditWordDoc_Click() Dim wordApp As
Word.Application Dim wordDoc As
Word.Document Dim wordRange As

Word.Range ' Open Microsoft Word in place and activate it.
Me![UnboundObj].Verb = -4
Me![UnboundObj].Action = 7

Set wordApp = Me![UnboundObj].Object.Application
Set wordDoc = wordApp.ActiveDocument
Set wordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="City")
wordRange.InsertAfter "Los Angeles"
wordApp.Quit
Set wordApp = Nothing

End Sub
12.. Save the form as frmBookmark, and then open it in Form view.
13.. Click the command button on the form and note that the document is
edited in place on the form, and that the words "Los Angeles" are inserted
after the City bookmark.
</pego>

Salu2
--
José Mª Fueyo
[MS MVP Access]
Batrrena
2007-01-19 15:48:40 UTC
Hola, perdon por no dar detalles. Se trata de Office 2000 y no me referia a
marcadores me referia a los campos que se utilizan cuando se hace un
formulario sobre word (parecido a los de la combinación de correspondencia)

De todas formas, muchas gracias por la info. Empezaré a darle vueltas a
partir de aqui. El problema fundamental es que sobre todo se me escapan las
colecciones de objetos que usa word. Voy a probar tambien en un grupo de
word.

Un saludo
Post by josé Mª Fueyo
Hola
Me imagino que te refieres a marcadores insertados en un documento de Word
¿no? bien. No nos comentas que versión de Office usas. Esto que he
encontrado está aplicado a Office XP, no es exactamente lo que quieres pero
creo que te pude dar pistas
<pego>
Finding a Bookmark in an Embedded Microsoft Word Document
By using Automation code in Microsoft Access, you can open a Microsoft Word
document and move to a bookmark location in the document.
The following example opens a document that is embedded in a Microsoft
Access form.
This example assumes that you have Microsoft Word set up on your computer,
that you have a document called C:\My Documents\WordTest.doc, and that the
document contains a pre-defined bookmark called City.
1.. Open the sample database Northwind.mdb.
2.. Open any module in Design view.
3.. On the Tools menu, click References.
4.. In the Available References list, click to select the Microsoft Word
10 Object Library check box. If this option doesn't appear in the list,
click Browse, locate the Msword.olb file, which is installed in the
C:\Program Files\Microsoft Office\Office10 folder by default, and click
Open.
5.. In the References dialog box, click OK.
6.. Create a new form that is not based on any table or query in Design
view.
7.. Add an unbound object frame control to the detail section of the form.
8.. When the Insert Object dialog box appears, click Create From File,
click Browse, select the C:\My Documents\WordTest.doc file and then click
Open.
9.. Click OK.
Unbound Object Frame
Name: UnboundObj
Locked: No
11.. Add a command button to the form; set its Name property to
Private Sub
EditWordDoc_Click() Dim wordApp As
Word.Application Dim wordDoc As
Word.Document Dim wordRange As
Word.Range ' Open Microsoft Word in place and activate it.
Me![UnboundObj].Verb = -4
Me![UnboundObj].Action = 7
Set wordApp = Me![UnboundObj].Object.Application
Set wordDoc = wordApp.ActiveDocument
Set wordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="City")
wordRange.InsertAfter "Los Angeles"
wordApp.Quit
Set wordApp = Nothing
End Sub
12.. Save the form as frmBookmark, and then open it in Form view.
13.. Click the command button on the form and note that the document is
edited in place on the form, and that the words "Los Angeles" are inserted
after the City bookmark.
</pego>
Salu2
--
José Mª Fueyo
[MS MVP Access]