Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2005

Tip: Looking for answers? Try searching our database.

Setting references programatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marc Hillman - 18 Jul 2005 09:02 GMT
I'm running Access 97 in a mixed Word 97 & Word 2003 environment, and using
OLE automation to transfer data from Access to Word. In order for this to
work I need a reference to "Microsoft Word X.0 Object Library" where X=8
(for Word 97)or 11 (for Word 2003). I know how to set this, but I never get
the chance. I get an error saying the reference is missing before I even get
to the form Open or Load method's to set the reference. How can I :-

a. Reliably detect which version of Word is installed, and
b. Set the reference before I load/open any forms?
_______________________________________
Marc Hillman, Melbourne, Australia
web: http://users.bigpond.net.au/mhillman/ 
Allen Browne - 18 Jul 2005 09:40 GMT
Hi Marc

It is nearly impossible to solve the problem the way you are seeking to. As
soon as VBA realizes that any reference is broken, it is too late to do
anything programmatically at all. The best reference I can suggest is
michka's article:
   How to guarantee that references will work in your applications
at:
   http://www.trigeminal.com/usenet/usenet026.asp?1033

The better approach is is use late binding. This MS article should get you
started:
   Microsoft Office 2000 automation Help file is available in the Download
Center
at:
   http://support.microsoft.com/default.aspx?scid=kb;en-us;260410

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> I'm running Access 97 in a mixed Word 97 & Word 2003 environment, and
> using OLE automation to transfer data from Access to Word. In order for
[quoted text clipped - 9 lines]
> Marc Hillman, Melbourne, Australia
> web: http://users.bigpond.net.au/mhillman/ 
Marc Hillman - 18 Jul 2005 11:33 GMT
Thanks for the quick reply, but I'm still a little stuck.

I have loop'ed through the References and detected that "Word" was not
loaded. Loaded it and all is fine.

Then I read Hint 8 of the first article where it says don't do this, but go
through the registry instead. How do I do that? What key am I looking for?
What VB functions allow Registry access?

I'm also having trouble with the Dir function. I want to locate MSWORD.OLB
so I can load it, but it's location varies according to Word version. Code
like strFilename = Dir ("C:\Program Files\Microsoft
Office\Office*\MSWORD.OLB") doesn't work. What's the trick?

> Hi Marc
>
[quoted text clipped - 26 lines]
>> Marc Hillman, Melbourne, Australia
>> web: http://users.bigpond.net.au/mhillman/
Allen Browne - 18 Jul 2005 13:11 GMT
Marc, I don't know the API calls off the top of my head, but you can
probabably adapt them from a VB site such as:
   http://vbnet.mvps.org/

Are you sure you don't want to use late binding?

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Thanks for the quick reply, but I'm still a little stuck.
>
[quoted text clipped - 37 lines]
>>> a. Reliably detect which version of Word is installed, and
>>> b. Set the reference before I load/open any forms?
Marc Hillman - 18 Jul 2005 13:21 GMT
I would use late binding, but I don't know what it is. The Office Automation
2000 help file isn't much help.

You've been very helpful already, but can I stretch the friendship and ask
for a code fragment to detect an absent or missing reference to Word?

> Marc, I don't know the API calls off the top of my head, but you can
> probabably adapt them from a VB site such as:
[quoted text clipped - 43 lines]
>>>> a. Reliably detect which version of Word is installed, and
>>>> b. Set the reference before I load/open any forms?
Marc Hillman - 18 Jul 2005 13:35 GMT
Ah, I am actually using late binding, but I didn't realise it.

The problem is that I wish to call Word, and wait till the user finishes. To
do this I have declared "Public WithEvents objWord as "Word.Application",
and respond to the Quit event. The "Word.Application" bit is the problem.
Public WithEvents objWord as Object isn't legal, so how do I do late binding
with a WithEvents?

> Marc, I don't know the API calls off the top of my head, but you can
> probabably adapt them from a VB site such as:
[quoted text clipped - 43 lines]
>>>> a. Reliably detect which version of Word is installed, and
>>>> b. Set the reference before I load/open any forms?
Allen Browne - 18 Jul 2005 13:49 GMT
The article I pointed you to is the best example I can give.

Perhaps others can help.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Ah, I am actually using late binding, but I didn't realise it.
>
[quoted text clipped - 40 lines]
>>>> at:
>>>>    http://support.microsoft.com/default.aspx?scid=kb;en-us;260410
Paul Overway - 18 Jul 2005 13:23 GMT
Use late binding. Otherwise, you're just making problems for yourself.

Signature

Paul Overway
Logico Solutions
http://www.logico-solutions.com

> Thanks for the quick reply, but I'm still a little stuck.
>
[quoted text clipped - 40 lines]
>>> Marc Hillman, Melbourne, Australia
>>> web: http://users.bigpond.net.au/mhillman/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.