VBA problem in new install

colblip

New Member
Outlook version
Email Account
POP3
I have code which has worked great on 3 different computers over the years. Now I am getting an error message on my latest computer. The code is for a macro that will select a specific contact view (I've got several different views and the project has several subs to view each of these). I am getting a compile error with the message - can't find project or library. Any help would be appreciated.

Sub GetViewChurch()

'Selects a new view
Dim olApp As Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim objName As NameSpace
Dim objViews As Views
Dim objView As View
Dim myolapp As Outlook.Application
Dim mynamespace As NameSpace

Set myolapp = CreateObject("Outlook.Application")
Set mynamespace = myolapp.GetNamespace("MAPI")
Set myolapp.ActiveExplorer.CurrentFolder = mynamespace.GetDefaultFolder(olFolderContacts)
Set olApp = Outlook.Application
Set objName = olApp.GetNamespace("MAPI")
Set myOlExp = olApp.ActiveExplorer

Set myFolder = objName.GetDefaultFolder(olFolderContacts) <<<<<<========= error here
Set myExplorer = myFolder.GetExplorer
'myExplorer.Display
Set objViews = objName.GetDefaultFolder(olFolderContacts).Views
myOlExp.CurrentView = "Church"

End Sub
 

colblip

New Member
Outlook version
Email Account
POP3
Diane,I don't expect you to remember, but you helped me create this code, 7 or 8 yrs ago. :)I finally got this working by copying my existing vbaproject.otm file (along with a number of others - nk2, etc.) to the new computer and fooling around with the digital signatures. For future reference, how does one 'set references...'?Thanks.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
So a digital signature caused problems? I'm surprised Outlook allowed you to open the VBE without telling you the signature was bad. (I'm getting that all the time lately after signing a macro then testing others and forgetting to resign it.)

This code shouldn't need references set because it only uses the outlook library and the reference to that should be set by default.

To check or set references - in the VB Editor, go to Tools, References. VBA, Outlook library should be selected by default.
 
Top