automate copying text in Word doc to Access db

D

davidtyler

I’m having trouble with the following process:

Access 2003 Database: WordDocImport.mdb
Table: WordDocText

Field_A: text field link/hyperlink to a MSWord document: C:\demowordfile.doc
- The document contains no fields and is merely text
Field_B: memo field currently empty

Need to: In a macro automate the process of importing/copying The text in the
Word document C:\demowordfile.doc into the Access table WordDocText’s Field_B

Thanks in advance for any assistance you can provide
David Tyler, Toronto, Canada
 
D

Dennis

Well, in VBA you need to add a reference to the MS Word Library. That exposes
all the MS Word functionality to your Access database. you can open a Word
doc ("invisibly" if you want, so the user doesn't see a Word aplpication
window open), "Select All" text, "Copy" that text, etc. Once you have all
those methods available to your VBA code, it becomes a simple mechanical
exercise. I spent MONTHS on this (gag) back when I had to learn how to do
it...

Dennis



davidtyler via AccessMonster.com said:
can't figure how to use only macros to accomplish this - even VBA code help
would be great - thanks
What kind of trouble are you having exactly?
I’m having trouble with the following process:
[quoted text clipped - 12 lines]

--



.
 
D

davidtyler via AccessMonster.com

Dennis - I feel you past pain - been going through the same thing myself - so
I really appreciate your response - been 'FileCopy' and 'Name As' waterlogged
and haven't been able to figure out automating SelectAll and Copy

so..... how do I add a reference to the MS Word Library?
Well, in VBA you need to add a reference to the MS Word Library. That exposes
all the MS Word functionality to your Access database. you can open a Word
doc ("invisibly" if you want, so the user doesn't see a Word aplpication
window open), "Select All" text, "Copy" that text, etc. Once you have all
those methods available to your VBA code, it becomes a simple mechanical
exercise. I spent MONTHS on this (gag) back when I had to learn how to do
it...

Dennis
can't figure how to use only macros to accomplish this - even VBA code help
would be great - thanks
[quoted text clipped - 6 lines]
 
D

Dennis

Open up the VBA code window. Then click on Tools / Refenrences. a HUGE (and I
do mean HUGE) list of references to various libraries will be displayed.
Scroll down until you find the one(s) for Microsoft Word (thank GOD they're
in alphabetical order) and click in the select box. Then save your VBA code
and the reference will save with it. Then you have all those methods at your
disposal. You'll need to play with them, as I don't remember how to use them
(it was about 4 years ago that I had to do it). But with that reference
selected, you have ALL the functionality of MS Word at your fingertips. You
can even change document formatting, Search for specifi text, do
find/Replaces, etc. It's way cool (heh)...



davidtyler via AccessMonster.com said:
Dennis - I feel you past pain - been going through the same thing myself - so
I really appreciate your response - been 'FileCopy' and 'Name As' waterlogged
and haven't been able to figure out automating SelectAll and Copy

so..... how do I add a reference to the MS Word Library?
Well, in VBA you need to add a reference to the MS Word Library. That exposes
all the MS Word functionality to your Access database. you can open a Word
doc ("invisibly" if you want, so the user doesn't see a Word aplpication
window open), "Select All" text, "Copy" that text, etc. Once you have all
those methods available to your VBA code, it becomes a simple mechanical
exercise. I spent MONTHS on this (gag) back when I had to learn how to do
it...

Dennis
can't figure how to use only macros to accomplish this - even VBA code help
would be great - thanks
[quoted text clipped - 6 lines]

--



.
 
D

davidtyler via AccessMonster.com

will give it a try - thanks so much
Open up the VBA code window. Then click on Tools / Refenrences. a HUGE (and I
do mean HUGE) list of references to various libraries will be displayed.
Scroll down until you find the one(s) for Microsoft Word (thank GOD they're
in alphabetical order) and click in the select box. Then save your VBA code
and the reference will save with it. Then you have all those methods at your
disposal. You'll need to play with them, as I don't remember how to use them
(it was about 4 years ago that I had to do it). But with that reference
selected, you have ALL the functionality of MS Word at your fingertips. You
can even change document formatting, Search for specifi text, do
find/Replaces, etc. It's way cool (heh)...
Dennis - I feel you past pain - been going through the same thing myself - so
I really appreciate your response - been 'FileCopy' and 'Name As' waterlogged
[quoted text clipped - 17 lines]
 
P

PieterLinden via AccessMonster.com

davidtyler said:
will give it a try - thanks so much
Open up the VBA code window. Then click on Tools / Refenrences. a HUGE (and I
do mean HUGE) list of references to various libraries will be displayed.
[quoted text clipped - 12 lines]

I just tried this... PAINFULLY SLOW. Wonder if it works better with ADO???

Private Sub cmdChooseWordDoc_Click()
Dim strFile As String
Dim appWord As Word.Application
Dim docWord As Word.Document

strFile = GetOpenFile("C:\", "choose a file")
Me.txtFolder = strFile

Set appWord = New Word.Application 'use get
appWord.Documents.Open strFile
Set docWord = appWord.Documents(strFile)
Me.txtContents = docWord.Content

docWord.Close False
Set docWord = Nothing
appWord.Quit
Set appWord = Nothing

End Sub
 
D

davidtyler via AccessMonster.com

Dennis & Pieter
I'm trying th folloing code but cannot get the text to copy
HELP :)

Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

' Now we open the canned response
Dim objWord As Word.Application
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open "C:\testworddoc.doc"""

' Select and Copy
objWord.Activate
Selection.WholeStory
Selection.Copy
Selection.End = True

' Then we just need to close the canned response
objWord.Activate
objWord.Quit


Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click


will give it a try - thanks so much
[quoted text clipped - 3 lines]
I just tried this... PAINFULLY SLOW. Wonder if it works better with ADO???

Private Sub cmdChooseWordDoc_Click()
Dim strFile As String
Dim appWord As Word.Application
Dim docWord As Word.Document

strFile = GetOpenFile("C:\", "choose a file")
Me.txtFolder = strFile

Set appWord = New Word.Application 'use get
appWord.Documents.Open strFile
Set docWord = appWord.Documents(strFile)
Me.txtContents = docWord.Content

docWord.Close False
Set docWord = Nothing
appWord.Quit
Set appWord = Nothing

End Sub
 
D

Dennis

How do you know the Copy isn't working?



davidtyler via AccessMonster.com said:
Dennis & Pieter
I'm trying th folloing code but cannot get the text to copy
HELP :)

Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

' Now we open the canned response
Dim objWord As Word.Application
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open "C:\testworddoc.doc"""

' Select and Copy
objWord.Activate
Selection.WholeStory
Selection.Copy
Selection.End = True

' Then we just need to close the canned response
objWord.Activate
objWord.Quit


Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click


will give it a try - thanks so much
[quoted text clipped - 3 lines]

I just tried this... PAINFULLY SLOW. Wonder if it works better with ADO???

Private Sub cmdChooseWordDoc_Click()
Dim strFile As String
Dim appWord As Word.Application
Dim docWord As Word.Document

strFile = GetOpenFile("C:\", "choose a file")
Me.txtFolder = strFile

Set appWord = New Word.Application 'use get
appWord.Documents.Open strFile
Set docWord = appWord.Documents(strFile)
Me.txtContents = docWord.Content

docWord.Close False
Set docWord = Nothing
appWord.Quit
Set appWord = Nothing

End Sub

--



.
 
D

davidtyler via AccessMonster.com

- The text isn't being highlighted and alson does not make it to the
clipboard
- getting an error: "Object variable ro With variable not set" as well
How do you know the Copy isn't working?
Dennis & Pieter
I'm trying th folloing code but cannot get the text to copy
[quoted text clipped - 53 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top