How to open Outlook form with VB code
Hi,
I have an Outlook public form that I want to open with VB code.
I've found here the next script, but I don't know what's the path to the form (I choose it from organizational forms library).
How can I found out the path? Is there another way to do it?
VB Code:
Private Sub Command1_Click()
Dim oApp As Outlook.Application
Dim oMsg As Outlook.MailItem
Set oApp = New Outlook.Application
Set oMsg = oApp.CreateItemFromTemplate("D:\Development\Outlook\Outlook Template\Message Test.oft")
If Not oMsg Is Nothing Then
oMsg.Display vbModal
Else
MsgBox "Couldnt find your template!"
End If
oApp.Quit
Set oApp = Nothing
End Sub
Re: How to open Outlook form with VB code
I remember that code :D
If you have a custom form that is not saved to the file system then you can create a new item in the folder that has that form as its default form. You can always .Move the item after if need be.
VB Code:
Dim oApp As Outlook.Application
Dim oMsg As Outlook.MailItem
Dim oFolder As Outlook.MAPIFolder
Set oApp = New Outlook.Application
Set oFolder = oApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("MySubFolderWithMyCustomForm")
Set oMsg = oFolder.Items.Add