cant find object using reference in workbook - vba

I'm trying to remove an old reference to Microsoft Office Web Components 11 (32 bit) in a workbook I'm updating, so it can run on office 365 (64 bit). I've removed all the objects I could find in sheets, and I've edited the code, so it now works, but I still get an error message saying:
Can't remove control or reference; in use
How do I find out where it is being used, so I can remove the reference and change it?

Related

"VBAProject" name conflict

My issue involves PowerPoint Add-Ins all being named VBAProject.
Microsoft Office Pro Plus 2010 - PowerPoint 2010 32 bit
Running Windows 7 Pro SP1 64 bit
I have several add-ins for PowerPoint saved as .PPAM files. In any PowerPoint file I can (or should be able to) link add-ins to extend that presentation's functionality. Each .PPAM file is named differently. In the VBA IDE however, in the list of references, each add-in is called 'VBAProject'. There are multiple entries of 'VBAProject' each one showing a path to a different .PPAM file. The problem is that I cannot add a reference to more than one add-in because the same name assigned to each of these; VBAProject. This results in a name conflict. Using the add-in manager from PowerPoint design view I can see all the selected add-ins as being 'active'. The Add-in manager for the VBA IDE shows no Add-ins.
Questions:
Is the naming of PowerPoint Add-ins as 'VBAProject' expected for every add-in?
Is there a way of change the name 'VBAProject' to something unique and hence avoid the name conflicts?
So it seems as if I have found the solution to my problem and would like to share it with the community. It involved a small change to the registry. [Be careful when dealing w/ the registry and make a back-up prior to any changes.]
From Regedit.exe -> HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\PowerPoint\Options. Change value of DebugAddins from 0x00000000 (0) to 0x00000001 (1).
With this done you will be able to see all the add-ins in the VBA IDE and from there you can change the name 'VBAProject' to something unique.

'Object Library invalid or contains reference to object' error

I had made an Excel macro using some ActiveX control buttons. It runs perfectly on my old PC. Some days back I purchased a new PC and when I compiled it reflect following error:-
"Object Library invalid or contains references to objects definitions that could not be found."
Also when I run this macro in design mode through the ActiveX button, it creates a sample blank module by a new default name corresponding to that button.
I tried everything that is available on the web. I even removed .exd files, checked my .ocx files. etc.
Now I am clueless about what to do as same macro is running perfectly on my colleagues laptop and they also have same version of Excel even.
Screenshot of the error that I am getting when compiling the code.

Excel oleobject cannot delete

I put date picker to my sheet and got a lot of problem
I cant select or delete thoose dtpickers nor manualy nor from VBA as this code
Dim obj As OLEObject
For Each obj In ActiveSheet.OLEObjects
obj.Delete
End If
Next
Return an error
application defined or object-defined error
I using Office 2013 32bit, other computers with Office 2010 32bit, Office 2007 32bit, Office 2013 32bit. I cant run compiled workbook on others computers, as i get in refences missing
microsoft windows common controls 2 6.0 sp6
Which also cannot be removed as is in use. I cannot uncheck it.
Most of my project functions and parameters such (Ucase, Mid, Left, wdAlignParagraphLeft) start getting error as undefined. Also all undeclared variables got the same error. Solving only by writing it with prefix VBA.Ucase, VBA.Mid and etc. and declaring all variables.
Also in developer tab insert control button not active anymore in all computers also in my computer too.
So question is? how to delete thoose dtpickers object and fix my project?
How to know what depend to microsoft windows common controls 2 6.0 sp6 library?
Remove protection from your sheet and then select and delete objects, after that go to VBA editor and uncheck this library from references and restart your Excel application.

Is the versions 12 vs 14 Object Library causing Excel VBA “Code execution has been halted”?

I have an Excel 2007 running the 12 Object Library. The macros run fine when opening the workbook in Excel 2007. However, there is a “Code execution has been halted” message whenever the macros are run in Excel 2010 (the actual break occurs during a ListObjects.Unlink method). I F8 through the breaks but it keeps stopping at each ListObjects.Unlink.
I checked the references on both versions of VBE. The Excel 2007 runs the Object Library Version 12 and the Excel 2010 runs Version 14. There doesn’t seem to be an issue running any other code. Any ideas of what is happening?
Another post on this site recommended clicking debug and pressing [Ctrl+Break] twice to continue. Is there another work around?
Thanks

Sheet.Activate is not working in Office 2010 - 64 bit

I have created a Macro which is working just perfect in my machine (Windows 64 bit & Office 32 bit)
But client is facing issue. He is having Windows 64 bit & Office 64 bit.
Don't know why but Sheet.Activate is not working on his machine. Refer below screen prints.
Based on your input, I cannot find back a declaration of "Recordsheet".
Since you input this code in the event routine "Workbook_open", I doubt that you did the declaration anywhere.
If you want to apply
RecordSheet.Activate
The least thing you should do is:
Set oRecordSheet = thisworkbook.sheets("Records")
oRecordSheet.activate
I strongly doubt that your version of Office / Windows has anything to do with it.
Vba is not supported by Microsoft anymore and no further developments to the language are made.
If it's a client, take into account the possibility that this client might have changed the name of the sheet.
In case you properly set the sheet object, this may also be the source of the problem.
Edit:
After looking at your file received by mail, I confirm that the above solution fixed the bug.
Replace the entire
UserForm_Initialize
Subroutine with:
Private Sub UserForm_Initialize()
Dim oRecordSheet As Excel.Worksheet
Set oRecordSheet = ThisWorkbook.Sheets("Expense Report")
oRecordSheet.Activate
EnableDisableConrols (False)
Call FillDropDowns
Navigator.Max = RecordSheet.UsedRange.Rows.Count
If RecordSheet.UsedRange.Rows.Count = 1 Then
RowNumber = 1
Else
RowNumber = 2
Call FillDataIntoControls
End If
End Sub
Edit 2:
The above solution is correct, BUT, if indeed the codename of your sheet is set to RecordSheet, you can use this solution too. However, note that the codename can only be used with the workbook.
I would think there may be missing references.
go to Tools -> References, and see if any are listed as missing
Remove the checkmarks there, and the basic stuff like date will start working again. If those references are critical to the code you are running, you will have to search out the 64 bit equivalents
More about references - normally resolving "Missing" fixes it, but, from here
What you're describing is typical of corrupted references. This can
be caused by a referenced file being a different version or in a different
location between the machine on which the code was developed, and the
client machines. Our company also tries to keep all the machines configured
the same way, but I've found it's essentially impossible to manage.
Open any code module (or open the Debug Window, using Ctrl-G, provided you
haven't selected the "keep debug window on top" option). Select Tools |
References from the menu bar. Examine all of the selected references.
If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.
If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Office may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)
(as a side note, disambigulating as VBA.xxxx will work, since Excel no longer has to
look through all of the references.)
The first line of your code shows a UserForm. Some widely-used form controls (those defined in the ComCtl library) don't exist in the 64-bit version of Office so it's highly likely that the UserForm is the problem.
There's no easy solution unless you can convince the client to use 32-bit Office instead or alter your UserForm so as not to use the affected controls.
Affected controls are: ImageCombo, ImageList, ListView, ProgressBar, Slider, StatusBar, TabStrip (although there is an alternative version of TabStrip in the normal MSForms library), Toolbar, Treeview
Details of the problem are discussed in this thread and confirmed here