A
A. Blundon
Hi folks,
I have a quick (yet probably easy question). I've done some VBA in
excel for the generation of engineering calculation spreadsheets but
this is my first kick at VBA in Outlook.
I'm trying to create a routine where I can click a message in my Inbox
(or elsewhere) and save this message to a msg file in a specific
locaiton. The file format and path for the save will be based on the
contents of the email subject, the send date, who it was from, etc.
I have this part of the routine working fine. I click a message, then
click the menu button, my form pops up it automatically fills in the
fields for date, subject etc. I can then click a save button and the
message will be saved to a msg file with the appropriate filename. The
next thing I would like to do is be able to leave the form open and
switch to a different message. When I switch, I'd like the date,
subject, sender info to be updated with the new message selected. From
what I can tell I need to use a selectionchange event to trap this.
I've never really worked with class modules before. From what I can
tell I have to create a new class module. I found this code on the net
and added it to the class module:
Dim WithEvents myolexp As Outlook.Explorer
Private Sub Application_Startup()
Set myolexp = Application.ActiveExplorer
End Sub
Private Sub myOlExp_Close()
' Need to do this so Outlook exits properly.
Set myolexp = Nothing
End Sub
Private Sub myOlExp_SelectionChange()
MsgBox "SelectionChange"
frmSaveMessage.lbltest.Caption = "Changed"
End Sub
When I add this code to ThisOutlookSession, the event triggers
everytime. I want it so that the event only triggers when I have my
form opened.
HELP!
Thanks,
AB
I have a quick (yet probably easy question). I've done some VBA in
excel for the generation of engineering calculation spreadsheets but
this is my first kick at VBA in Outlook.
I'm trying to create a routine where I can click a message in my Inbox
(or elsewhere) and save this message to a msg file in a specific
locaiton. The file format and path for the save will be based on the
contents of the email subject, the send date, who it was from, etc.
I have this part of the routine working fine. I click a message, then
click the menu button, my form pops up it automatically fills in the
fields for date, subject etc. I can then click a save button and the
message will be saved to a msg file with the appropriate filename. The
next thing I would like to do is be able to leave the form open and
switch to a different message. When I switch, I'd like the date,
subject, sender info to be updated with the new message selected. From
what I can tell I need to use a selectionchange event to trap this.
I've never really worked with class modules before. From what I can
tell I have to create a new class module. I found this code on the net
and added it to the class module:
Dim WithEvents myolexp As Outlook.Explorer
Private Sub Application_Startup()
Set myolexp = Application.ActiveExplorer
End Sub
Private Sub myOlExp_Close()
' Need to do this so Outlook exits properly.
Set myolexp = Nothing
End Sub
Private Sub myOlExp_SelectionChange()
MsgBox "SelectionChange"
frmSaveMessage.lbltest.Caption = "Changed"
End Sub
When I add this code to ThisOutlookSession, the event triggers
everytime. I want it so that the event only triggers when I have my
form opened.
HELP!
Thanks,
AB