Ifyou use the objects in other applications as part of your Visual Basic application, you may want to establish a reference to the object libraries of those applications. Before you can do that, you must first be sure that the application provides an object library.
The References dialog box shows all object libraries registered with the operating system. Scroll through the list for the application whose object library you want to reference. If the application isn't listed, you can use the Browse button to search for object libraries (*.olb and *.tlb) or executable files (*.exe and *.dll on Windows). References whose check boxes are selected are used by your project; those that aren't selected are not used, but can be added.
Select the object library reference in the Available References box in the References dialog box and choose OK. Your Visual Basic project now has a reference to the application's object library. If you open the Object Browser (press F2) and select the application's library, it displays the objects provided by the selected object library, as well as each object's methods and properties.
In the Object Browser, you can select a class in the Classes box and select a method or property in the Members box. Use copy and paste to add the syntax to your code.
I'm trying to write in a Word document from Excel VBA code, to place the data from am Excel table into a report. I added the "Microsoft Office 16.0 Object Library" to be able to work with Word objects from Excel, and in my code I defined variables as Word.Application, but when I run it, my program can't recognize this type.
In the "Tools >> References..." dialog box I can see that the location of this library is in "C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16\MSO.DLL", but when I access this folder "OFFICE16", to check what's inside, I can't find the archive MSO.DLL (I only see the "Office Setup Controller" folder, and the LICLUA.EXE archive).
"Microsoft Office 16.0 Object Library" does not contain the classes, etc., you are looking for, i.e., Word classes. Scroll further down in the References dialog to find "Microsoft Word 16.0 Object Library", and select it.
Then open the Object Browser (under the VBA Editor's View menu); select Word from the upper dropdown list (which usually shows ) to see a top-level view of this library's classes. You can click on a class name to see its members, and click on a member name to see more info on it in the pane at the bottom (which has a draggable border, so you can make it taller/shorter).
@PacoDeBenito I realize this is an older thread and hopefully you've already found a solution. I wanted to post for anyone else who comes across this thread having the same issue. I was struggling with this same thing. I had the "Microsoft Office 16.0 Object Library" selected in References but VBA was still not recognizing the Word.Application object. After searching through the list I found an available reference called "Microsoft Word 16.0 Object Library" and as soon as I activated that, the Word.Application object worked perfectly. I hope this helps!
A friend of mine is missing the Microsoft Office XX.0 Object Library. He has office 2016 installed. He is using a code that I generated to export a bill of materials from Inventor to excel. A reference to the Microsoft Office XX.0 Object Library is required. This object Library is not present in the References window (VBA>Tools>References). Is there a way to download another/find in his directory?. Would I be able to give him a copy of my object library? If so, what would be the filename for the library?
I figured it out though. The main issue I was having was determining the location and name of the dll file. For me, the object library was only missing from the references window while using vba editor in Inventor. When I open up excel and pull up its vba window, the object library was not missing from the list.
So I clicked on the Microsoft Office 16.0 Object Library from the excel vba references window and it shows the full file path. But it cuts off before the end. I had a nightmare with this and Microsoft help chat/calls.
The next morning I opened Visual Studio 2015 and opened a Visual Basic > Windows > Classic Desktop > Console Application. From the Solution Explorer, I right clicked References > Add Reference. A window came up with an extensive list of object libraries. I found the Microsoft Office 16.0 Object Library that I was looking for, and when I put the cursor over the listed object library, it displayed the full path and file name uncut and uncensored.
Finally, I went back into the inventor vba window > Tools > References. I then clicked browse in the new window and found my dll file. It was named Office once it was in the References window. I closed the references window and reopened it to find the Microsoft Office 16.0 Object Library just as it should be. All of this just so I can create File Dialogs!
Anyways, I can't imagine I am the only one in the world who had or is having this issue with an object library. For Office 2016, here is the full file path, which I imagine will be the same for any user because I believe it is a default directory:
If anyone is having a similar issue with an object library and they know it is on their computer somewhere, employ the aforementioned method using Visual Studio 2015; Community Edition should work fine.
Rgds, Geoff
Never test the depth of water with both feet
Help us to help you by reading FAQ222-2244 before you ask a question RE: Missing object library reference dean12 (MIS)(OP)27 Jul 04 14:49Yea, that's probably true --- but across an entire organization, what a job. RE: Missing object library reference sdraper (Programmer)27 Jul 04 15:28look at early vs late binding. I am sure there are several threads about it on this forum. Sam
RE: Missing object library reference dean12 (MIS)(OP)27 Jul 04 17:48Well, the early .vs. late binding issue has come up before but frankly that's where I get lost. The issue here is I think the MS Office 99.9 Object library.
From VBA, what would I do differently than I have already done that would make the whole thing portable between different versions of Excel?
For example, I create a new spreadsheet with absolutely no attached VBA code - no macros. I store a number or two, save the spreadsheet, and then send it to you. You open it with your version of Excel ---- no problems ---- why?
Next I add VBA code into "This Workbook" that says:
Option Explicit
Private Sub Workbook_Open()
'
' Flip between two sheets to force the sheet activation event
' to occur. This event will not happen if our final sheet is
' already active.
'
Application.ScreenUpdating = False
sh01.Activate
sh00.Activate
Application.ScreenUpdating = True
End Sub
and now the thing won't work when I send it to you and you have a different version. What about this code am I supposed to early or late bind? We can't say late bind the Application object because the Application object is already in execution - I think. I don't know, frustrating as I honestly do not fully understand the failure to begin with.
RE: Missing object library reference xlbo (MIS)28 Jul 04 04:14You are not quite right in asserting that a spreadsheet created in 1 version of excel will be ok in another - it may be for some / the majority of functions but there will be some functions that are not backwards compatible - same thing goes for code but the important difference is that the VBA code must be compiled BEFORE it can be run and if a function does not exist or the wrong library is being referenced, it cannot compile.
Having said all of that, the code you posted should work on any version of excel higher than '95 - you should only really see issues when attempting to invoke foreign object libraries ie if you are using Access to open Excel then you would need to reference the correct object library but internal code should be fine..... Rgds, Geoff
Never test the depth of water with both feet
Help us to help you by reading FAQ222-2244 before you ask a question RE: Missing object library reference dean12 (MIS)(OP)28 Jul 04 13:29Maybe my lack of complete understanding on this is causing a communication problem.
It appears to me that when you work with Excel certain object libraries are involved and these can be found by ALT-F11, TOOLS, References.
On my system, I open Excel and I have a blank, virgin worksheet displayed. ALT-F11, Tools, References shows the following references checked:
Visual Basic for Applications
Microsoft Excel 10.0 Object Library
OLE Automation
Microsoft Office 10.0 Object Library
It's the "MIcrosoft Office 10.0 Object Library" that becomes the problem. I send my spreadsheet to someone with a different version of Excel and they don't have the "Office 10.0", they have "9.0" or "11.0". Now we have a problem because there is a reference to an object library that is missing so the spreadsheet fails to start and the end user has to go into TOOLS --> REFERENCES and uncheck the "10.0" and check whatever version they have.
I really don't care so much what causes the problem, I'm just trying to ascertain how to resolve the issue in a more automatic fashion than manually editing references.
Maybe there is some way for each user to have version 9, 10, and 11 of the Microsoft Office Object library and then it would not be a problem - maybe so?
RE: Missing object library reference xlbo (MIS)29 Jul 04 03:47Well my point about having a standard OS and set of applications is the best course of action. If this isn't feasible for whatever reason (we seem to have managed it here) then you need to get your users to understand the limitations.
A workbook created in 2000 should be able to be opened in XP or 2003. A workbook created in 2003 may well not open in 2000. In all versions of excel / office apps, there is an option to SAVE AS a previous version so in excel 2003 you can save as 2000 - that way the workbook can be opened in 2000, XP or 2003.
As far as I know, there is no way of having multiple object libraries and getting them to self reference - I believe it can be done via code but it would almost certainly be long and involved and the code would have to be attached to every excel workbook.
Having read your 1st post again, this may be a viable course of action if there is only 1 (or a couple) problematic workbook Rgds, Geoff
Never test the depth of water with both feet
Help us to help you by reading FAQ222-2244 before you ask a question RE: Missing object library reference dean12 (MIS)(OP)29 Jul 04 10:48I want all of you who have responded to know that I am grateful for the dialog on this subject and if anyone feels I have taken issue with them, I sincerely apologize. I am simply going over this issue repeatedly and from different directions because it confounds me and in the midst of that confusion I am not sure that I am being clear about the issue.
I have forwarded and received hundreds if not thousands of spreadsheets over the generations of Microsoft Office and this issue does not seem to come up until VBA code is inserted. How on God's green Earth Microsoft expects their office users to: (1) never use code behind a spreadsheet or (2) be able to nagivate the solution of setting object library references is beyond me. I guess that's what seems so stupid to me and since it seems stupid, I begin to feel I am in some way stupid and missing the solution.
RE: Missing object library reference xlbo (MIS)29 Jul 04 11:12dean12 - don't beat yourself up over this. I don't think anyone feels like you have taken issue with them - I certainly don't.
I am a little confused as both the organisations I have worked for (in the past 5 years) have had a corporate office solution ie everyone is on the same OS and the same version of Office Apps - I guess that is exactly as M$ would like it to be - ergo everyone upgrades at the same time and they get another nice fat slice of upgrade fee
I'm pretty sure I understand the issue and as I mentioned in my last post, I'm pretty sure that a solution could be set up for a few spreadsheets (seems like VB apps must do this quite a lot) - whether that would fix the issue is another matter as you would then have to keep applying the fix to new spreadsheets as they are created - it certainly wouldn't be a global fix as it would have to be applied as code to each workbook in turn in the wb_open event
Might be worth asking the question about setting references dynamically in the VB5/6 forum as I'm sure they must deal with this kid of scenario more
Anyways - hope you have had at least some half decent ideas here
Peace Rgds, Geoff
Never test the depth of water with both feet
Help us to help you by reading FAQ222-2244 before you ask a question RE: Missing object library reference dean12 (MIS)(OP)29 Jul 04 15:59I understand the corporate license process and you are probably correct that that will ultimately be the way we have to go. Our financial group called me a couple of days ago and that's one of the things I spoke to them about - acquisition of a corporate license. My response was "Let's run this up the pole one last time and make sure I haven't missing something.".
RE: Missing object library reference JoeZim (MIS)29 Jul 04 16:57I have run into a similar situation, but my problem was with Windows XP versus NT. Anyways, I had to create a patch macro to update an object library (I currently run this patch macro from my Personal.xls file).
In your case, here is a sample of code to find out which version of excel the current machine has installed:
Private Sub CommandButton1_Click()
Dim versiontype As String
versiontype = Application.version
MsgBox "Microsoft Excel " & versiontype & " Object Library"
Select Case versiontype
Case "9.0"
MsgBox "Success"
Case "10.0"
MsgBox "Fail"
Case "11.0"
MsgBox "Fail"
End Select
End Sub
Now, in the action statements of the Cases, you could use the following code to update the appropriate object library:
Set ThisProj = ActiveWorkbook.VBProject
ThisProj.References.AddFromFile "C:\Program Files\Microsoft Office\Office\MSACC9.OLB" (This example is adding the Microsoft Access 9.0 Object Library. You will need to find the location of the reference file and proper library type.)
I know how frustrating this problem can be, so I thought I would at least give you some samples that helped me.
Joe
RE: Missing object library reference xlbo (MIS)30 Jul 04 04:00Nice Joe - like it
Have a ppt Rgds, Geoff
Never test the depth of water with both feet
Help us to help you by reading FAQ222-2244 before you ask a question googletag.cmd.push(function() googletag.display('div-gpt-ad-1406030581151-2'); ); Red Flag This PostPlease let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.
CancelRed Flag SubmittedThank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.
3a8082e126