Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Reference Blues

Status
Not open for further replies.

stingers

Programmer
Jan 13, 2002
40
US
I am working with an Access97 application that uses several (6) references. The application is installed on machines that run MS Office 97, 2000, and 2002...so the references are different for each machine. I have imple4mented the fix in Microsofr KB article Q194374, which works ok for most of the references except the Word and Outlook one. I have found the outlook has changed the guid, so i must implement late binding ... no biggie. But the code in the kb article also does not replace the ms word reference, it only removes it??? Any suggestions for handeling the references through code?

Thanks in advance.


(My machine has office 2002 on it, so it uses MS Word 10 Library, oin my test machine I have office 97 installed (MS Word 8 Library)
 
You need to locate the files that will be used in the references which can be found from the reference dialog box.
Example of setting in code. Examples sets a reference to the latest ADO library - do the same for all libraries.

Function ReferenceFromFile(strFileName As String) As Boolean
Dim ref As Reference

On Error GoTo Error_ReferenceFromFile
Set ref = References.AddFromFile(strFileName)
ReferenceFromFile = True

Exit_ReferenceFromFile:
Exit Function

Error_ReferenceFromFile:
MsgBox Err & ": " & Err.description
ReferenceFromFile = False
Resume Exit_ReferenceFromFile
End Function

Function CreateReference()
'- add the libraries here as per example.

If ReferenceFromFile("C:\Program Files\Common Files\SYSTEM\ADO\msadox.dll") = True Then
MsgBox "Reference set successfully."
Else
MsgBox "Reference not set successfully."
End If
End Function
 
I think I might be dealing with a similar issue in a different way and I'm stuck....

I am developing on a PC which has Office2000 and Access97 installed. An admin did this install for me, I have no idea how she did it, and I'm now in a remote office in the fields of Brazil with little access to software and trying to get this fixed. I think I must have some sort of reference issue, but I'm not sure what it is.

What I'm trying to do is develop an application in Access97 that pulls some of its data from Excel. I have a reference to Microsoft Excel 9.0 Object Library, the file is EXCEL9.olb (stupid question, I'm sure, but what is an olb file, and can I register it??). I can dim excel variables, such as Workbook or Excel.Workbook, and intellisense kicks in, but when I try to use them, such as Set wb = New Workbook, I get activex component can't create object error.

I've been out of VBA for a long time, and am probably missing something stupid, but I am really hung up on this,
and if I don't get it resolved, I don't get to go home! :)

Please, ANY suggestions are greatly appreciated!!!

Thanks--
Sheri
 
cmmrfrds; thanks for the response, but with all due respect I dont think that your solution will work. You assume that all computers have the libraries installed in the same place, when in reality the libraries are installed ion different directories on different computers (operating syatems) e.g. Win 2000 stores the libraries in one place and NT another, my machine here I have the olb files in c:\program files\microsoft office\office10\*.olb and at work, where I have office 2000 and 97 installed, c:\program files\microsoft office2k\office 10\*.*

If i am missing something please advise...thanks for the try too.
 
Yes, the example assumes the path structure is known - the functions will still work, but since the locations are different on each OS then you will need to dynamically locate the file and the file's path. The File Scripting Object (FSO) can be used to do this. It will take a bit of coding but is doable, in fact, you can probably find code on the internet. Here are a couple of links to give some background on FSO and how to find a file and locate its full path. You can still use the functions provided after locating the path and putting the path in a variable. You will need to set a reference to the vb microsoft scripting runtime library.

File Scripting Object links to check out.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top