Tuesday 29 March 2016

vba - I am getting 'Compile error: Can't find project or library' in a only some Excel 2010 versions. Difficult to test this



My customer is getting a Compile Error; Can't find project or Library on his version of Excel 2010, however i am not getting this on my version of 2010. How can i adjust this code so it will not appear. When the error appears in the following code the text "cell" in "For each cell in selection" is highlighted:




Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$9" Then
Columns("D:CB").Select
Selection.EntireColumn.Hidden = False
Application.ScreenUpdating = False

Sheet17.Range("E48:CB48").Select

For Each cell In Selection

If cell = 0 Then
Range(cell.Address).EntireColumn.Hidden = True
End If
Next

Application.ScreenUpdating = True
Sheet17.Range("b9").Select
End If

End Sub`



My customer is also reporting a bug in the following code with the word "Response" being highlighted. This, as well, is not an issue for me, on my version of Excel 2010. Any and all help is greatly appreciated.



If Sheet1.Range("E18") = 3 Then
Response = MsgBox("Reminder Emails have been set to be sent automatically at " & Sheet1.Range("f18").Value & ", " & Sheet1.Range("Q4").Value & " day(s) before" & vbCrLf & "the scheduled appointment. Do you want to send reminder e-mails now anyway?", vbYesNo)
If Response = vbNo Then
Exit Sub
End If
End If


Answer



In the VBA window, go to Tools --> References and ensure the same libraries are toggled on for all computers. Also make sure all active libraries are in the same order top-to-bottom.



Many libraries "come standard" but one may need to be toggled on. Or, a library reference may need to be toggled off due to a functional interference. A library may be altogether missing, but I doubt this is the case since it's a fairly standard suite and you aren't aware of having tinkered with it.



This is a typical issue and usually not considered too great a burden on your distribution clientele. If it is, you can rework your code to use fewer references; or you may be able to load the needed libraries programmatically (but I haven't ever tried that).



I suggest you include Option Explicit at the top of all modules. This problem looks a bit like a failure to declare your variables; and I think that requirement can vary by setting. Option Explicit will force all variables to be declared, which is beneficial in general and could cause all client installs to act the same.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...