Link to home
Start Free TrialLog in
Avatar of edogroen
edogroen

asked on

Insert Info from Access Database in Word though a Word-macro (VBA)

Is it possible to lookup some information in an Access database, let say an address and insert it in a Word using a word-basic Macro? I cannot find info on this in the Word- or VBA-helpfiles.
Avatar of Chrrris
Chrrris

Yes, it is possible!

I am working on an application that requires something
similar to this. I need to keep track of, open, and access
information (such as the document title) in word documents.

If you are interested, I can give you a code example that
sends an Word fax from Access.

I would be interested :-)

to edogroen: which verisons are you using ?
OOOOPS ! I'm sorry ! This should me a comment not a proposed answer .. deny it please !
Avatar of edogroen

ASKER

BBC: I use Office'95. So Version 7 of both programms.

Chrrris: I am not sure if that is the same. I want to import a single address from Access in Word using a Word-macro. I think you make a Word-document from Access. As far as I tried the VBA-commands for using Access use (from Word) don't work. In the Word-helpfiles there is no VBA-info for doing this. Only the Mailmerge option. I hope that what I wrote here makes sence!?!
Please rate my "answer" with the lowest possible rating (think its E) so someone other can give you a real answer, please !

OK, Acces is NO OLE Server ! That means that you can't access to Access from the outside ! Do not blame me .. you know who to blame ...
The only way would be, that you start Access, which automatically starts its own makro and waits for signal from word for executing a special action, which has to be programmed in Access. Sorry, I think there is no other way !
If this way may be good for you, tell me, I'll try a little. But can you start Access from Word ?
Ahhh, now I have another idea !
With the /x option you can execute a macro in Access, so you could easily "trigger" that action you want to have done from the outside.
Need an example ?

Uhhh. You are right, edogroen. I am trying to do the opposite!

BBC, I think it IS possible to retrieve information from Access via word macros. How come you believe this isn't the case?


BBC: OK I rejected your answer. I will think about you option, but it sounds complicated to it that way and it will slowdown do process since you _have_ to start Access.

Chrrris, any idea how?
Both:
Okay, I only have Access 97 handy. So I looked in the documentation there. I found something really new. It wasn't there in Access 2, so perhaps its already there in 95 ?

In 97 you should be able to open Access and access the forms and reports. Over DBEngine you probably will be able to access the tables and their contents .. is that what you wanted ??

Here is the beginning:  

Dim appAccess As Object
Set appAccess = CreateObject("Access.Application.8")    
                                   Use 7 here ^^^^^^^ ????
appAccess.OpenCurrentDatabase "myData.mdb"
...


If you can find these methods in Access 95 and get this little bit of code above running, I will program the rest for you ...
L8ter!
See? I knew it was possible ;)z-<
:))) Chrrrris, can U test the code above in Office 95 ? Do you have that ?
Sorry mate, I only have Access 97.
Hej,

The code above doesn't work in Office'95. I think I have to wait untill we upgrade to Office'97. Or I have to use a normal textfile as my database. Just open this file and read the contents. It is not like I want it but it is an alternative to consider.

Thanx so far.
Edo
ASKER CERTIFIED SOLUTION
Avatar of mikkon
mikkon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanx,

That is what I basicly already knew. But thanx anyway for the exact explanation and the info on Word 97.

Bye,
Edo