Macro to bring up a Custom Form

S

Shauna Koppang

I am trying to modify a macro to pull a custom Contact
Form from my Personal Forms Library called "Change File As
Fields", that I will activate using a new tool on my
toolbar.

This code I originally found through Microsoft
Knowledgebase.

To manually run the form I am in Contacts, then choose
File menu, New, Choose Custom Form, then choose Personal
Forms Library, then the form Change File As Fields, and
click OK.

When I run the macro as it stands it brings up New Mail
Message not my custom form. Can anyone help me change my
code to pull up my custom form? THANKS!!!

Shauna

Sub RunMyForm()
Dim myOlApp As Application
Dim myNameSpace As NameSpace
Dim myFolder As MAPIFolder
Dim myItems As Items
Dim myItem As Object

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = _
myNameSpace.GetDefaultFolder(olFolderContacts)
Set myItems = myFolder.Items
Set myItem = myItems.Add
("IPM.Contacts.Change_File_As_Fields")
myItem.Display

Set myOlApp = Nothing
Set myNameSpace = Nothing
Set myFolder = Nothing
Set myItems = Nothing
Set myItem = Nothing
End Sub
 
S

Sue Mosher [MVP]

I'd suspect a typo in the form name in your code, although even with that, I'd expect you to get a generic contact form.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
N

NS

This is what I used to accomplish the exact same thing using a custom task
form:

Public Sub DisplayForm()
Set myFolder = Session.GetDefaultFolder(olFolderInbox)
Set myItem = myFolder.Items.Add("IPM.Task.PR")
myItem.Display
End Sub

I think the form would also have to be in your Contacts folder, as I
originally had the form stored in my Personal folder, but didn't find the
VBScript equivalent for the Session.GetDefaultFolder parameter, so I saved
it under the Inbox Folder, and now it works.

Hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top