Convert Word Macro to Access Procedure?

T

Tom Brown

Is it possible to convert a VBA Macro from MS Word into an Access VBA
Procedure? Instead of running the procedure (Macro) from MS Word, I would
like to run it from an Access form with a Command Button. The goal is to
extract data from a Word document into an Access table.

For example, the following line gets a compile error

vCity = Source.FormFields("City").result



It tells me "The Method or data member is not found." The .FormFields is
highlighted on the error.



Any help will be appreciated,



Tom
 
G

Guest

Hi Tom,

Yes, this should be possible. Start by writing early bound code so that you
will have intellisense to help you. You'll need to set a reference to the
"Microsoft Word X.XX Object Library", where X.XX represents your version of
Word. Then you'll need to declare an object variable and set it in the
procedure, like this:

Dim objWord As Word.Application
Set objWord = GetObject(, "Word.Application")

(You don't need to name it "objWord"--you can name it whatever you want).

An example of retrieving data from a Word document into an Access table can
be found here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnimo01/html/imo1200.asp

I have a copy of the sample database that goes with this article. If you
send me a private e-mail message, with a valid reply-to address, I will send
you this file. My slightly obfuscated e-mail address is shown below. You
should have 18 characters remaining, after removing the indicated letters and
spaces. Whatever you do, please do not post your unaltered e-mail address to
any newsgroup message.


Tom

QWaos168@XScom cast. Dnet (<--Remove all capitalized letters and spaces).
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Is it possible to convert a VBA Macro from MS Word into an Access VBA
Procedure? Instead of running the procedure (Macro) from MS Word, I would
like to run it from an Access form with a Command Button. The goal is to
extract data from a Word document into an Access table.

For example, the following line gets a compile error

vCity = Source.FormFields("City").result



It tells me "The Method or data member is not found." The .FormFields is
highlighted on the error.



Any help will be appreciated,



Tom
 

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