Open Contact From Folder

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
When I open a contact from clicking on the name of the contact that sends me an email, some of the macros that are in the contact form do not work unless I open the contact from the contact folder it is in. So I have a macro added to the contact form that shows the contact folders so I run that macro, select the contact again from the folder that opens and the other macros work with the contact, and it also closes the contact that opened from the email that I opened it from.

So is there a code that I put in the macro that opens the contact folder, that automatically opens the contact that is the contact I run the folder macro from?
 
Yeah, you should be able to automate the search and opening of the contact, but I don't have any code handy.

What macros won't run from the contact? You might be able to fix that so you don't need the other one.
 
I have the codes that either delete the words of a field or move the words to another field....so here is the examples and if there is away to change so it works, I will change all the other same type codes that do the same thing

Sub ConvertStatusDatetoStatus1Date()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim ObjItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objSelection = objApp.ActiveExplorer.Selection

For Each ObjItem In objSelection

ObjItem.UserProperties("Status 1 - Date:") = ObjItem.UserProperties("Status Date")

ObjItem.UserProperties("Status Date") = ObjItem.UserProperties("NoneDate")

ObjItem.Save

Next

Set ObjItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing

End Sub

Sub DeleteRelatedStatus()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim ObjItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

Set objSelection = objApp.ActiveExplorer.Selection

For Each ObjItem In objSelection

ObjItem.UserProperties("Related Status") = ""

ObjItem.Save

Next

Set ObjItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing

End Sub
 
This is the problem - it's looking for the selection. when you use a macro to open the contact from the folder you aren't using the opened contact, you are using the selected contact.

Set objSelection = objApp.ActiveExplorer.Selection
For Each ObjItem In objSelection
ObjItem.UserProperties("Status 1 - Date:") = ObjItem.UserProperties("Status Date")
ObjItem.UserProperties("Status Date") = ObjItem.UserProperties("NoneDate")
ObjItem.Save
Next

I'd use the function (which i think you have already) from http://www.slipstick.com/developer/outlook-vba-work-with-open-item-or-select-item/ so it works with both open or selected items.

otherwise, you need to use

Set objItem = objApp.ActiveInspector.CurrentItem

Do you need it to work with multiple items at once or do you only use it on one contact at a time?
 
This is the problem - it's looking for the selection. when you use a macro to open the contact from the folder you aren't using the opened contact, you are using the selected contact.




Set objSelection = objApp.ActiveExplorer.Selection



For Each ObjItem In objSelection



ObjItem.UserProperties("Status 1 - Date:") = ObjItem.UserProperties("Status Date")



ObjItem.UserProperties("Status Date") = ObjItem.UserProperties("NoneDate")



ObjItem.Save



Next





I'd use the function (which i think you have already) from http://www.slipstick.com/developer/outlook-vba-work-with-open-item-or-select-item/ so it works with both open or selected items.




otherwise, you need to use


Set objItem = objApp.ActiveInspector.CurrentItem




Do you need it to work with multiple items at once or do you only use it on one contact at a time?
 
I use to select more than one contact from a folder....and then sometimes I need to use it when I just have opened one contact.....so what do I do?
 
Two choices: a second macro to this macro checks to see if you have a contact open. I think i prefer 1 macro and check to see if a contact is open - assuming you don't normally keep a bunch of contacts open all day. I'll have to think about it more.
 
One macro that can do both would be great as I don' try to do it from more than one contact open.....just one contact open or selected contacts not open
 
See if these macros work - i wanted to reuse the same lines, but can't because of the loop the selection needs.

Sub ConvertStatusDatetoStatus1Date()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim ObjItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")


On Error Resume Next

If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set ObjItem = objApp.ActiveInspector.currentItem
ObjItem.UserProperties("Status 1 - Date:") = ObjItem.UserProperties("Status Date")
ObjItem.UserProperties("Status Date") = ObjItem.UserProperties("NoneDate")
ObjItem.Save

GoTo Leave

End If
Set objSelection = objApp.ActiveExplorer.Selection
For Each ObjItem In objSelection
ObjItem.UserProperties("Status 1 - Date:") = ObjItem.UserProperties("Status Date")
ObjItem.UserProperties("Status Date") = ObjItem.UserProperties("NoneDate")
ObjItem.Save
Next

Leave:
Set ObjItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
Sub DeleteRelatedStatus()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim ObjItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

On Error Resume Next

If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set ObjItem = objApp.ActiveInspector.currentItem
ObjItem.UserProperties("Related Status") = ""
ObjItem.Save

GoTo Leave

End If
Set objSelection = objApp.ActiveExplorer.Selection
For Each ObjItem In objSelection
ObjItem.UserProperties("Related Status") = ""
ObjItem.Save
Next

Leave:
Set ObjItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
 
So the change is simply add: and I did it and it works perfectly whether open a contact or just select a contact

On Error Resume Next

If TypeName(objApp.ActiveWindow) = "Inspector" Then

Set ObjItem = objApp.ActiveInspector.currentItem

ObjItem.UserProperties("Related Status") = ""

ObjItem.Save

GoTo Leave

End If

And the word "Leave:) before Set ObjItem = Nothing
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Outlook 2007 Open Folder From a Contact Using Outlook 22
L Outlook 2007 Macro Open Contact Folder Using Outlook 7
L Macro to Open a Contact Folder Using Outlook 15
Witzker Outlook 2019 Edit contact from email does not open the user defined contactform Using Outlook 3
Witzker Open Contact missing in Outlook 2019 Using Outlook 2
Z Outlook 2007, clicking email addresses fails to open Contact Using Outlook 0
A Cannot edit or open existing contact nor add new ones. BCM (Business Contact Manager) 1
E Double clicking on from email address does no longer open corresponding contact in Outlook 2007 Using Outlook 7
C Business Contact manager wont open BCM (Business Contact Manager) 1
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
Rupert Dragwater How to get Outlook 365 to open from websites Using Outlook 5
S Leaving ActiveExplorer open for editing after Sub is done Outlook VBA and Custom Forms 0
Commodore PDF attachments started to open in Edge Using Outlook 0
T Outlook 2021 Cannot open attachments Outlook DeskTop 2021 Using Outlook 0
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
talla Can't open Outlook Item. Using Outlook 0
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
K Embedded photos no longer open with Photos or Photo Viewer Using Outlook 7
L Cannot open PST file for first session each day Using Outlook 6
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
sahameed82 SharePoint calendar directly open in Outlook Using Outlook 0
N .pst archive from work will not open/import on Microsoft 365 Exchange Server Administration 0
C Outlook 2016/2019 hangs after being open for an extended period Using Outlook 4
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
W Automatically open attachments without automatically printing them Using Outlook 0
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
J How to open OST file in Outlook 2019 & 2016 Using Outlook 1
C Can't Open Outlook 365 Using Outlook 0
D after delete mail, open the next one Outlook VBA and Custom Forms 0
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
M outlook won't open! Using Outlook 1
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
M other user's mailbox won't open, forms disappeared Using Outlook 42
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
D Add Tetxbox at form open Outlook VBA and Custom Forms 1
U Catching ModuleSwitch events after "open in new window" Outlook VBA and Custom Forms 2
Andrew Quirl Open attachment, manipulate without add-on program? Outlook VBA and Custom Forms 5
S Reminder Dialog Open Button Using Outlook 2
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
S Outlook 2010 Cannot Open Attachments Using Outlook 14
N open the hyperlink in Outlook directly instead of browser Using Outlook 1
S Outlook does not open the .pst file created by the Outlook Using Outlook 5
A open Outlook with multiple windows. Using Outlook 0
K open calendar from address book Outlook VBA and Custom Forms 1
T Double clik behavior on agenda open a new meeting request Using Outlook 1
E Open olNoteItem Attachment Outlook VBA and Custom Forms 6

Similar threads

Back
Top