![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Thanks for taking the time to read my question.
I'd like to make a button on my tool bar in Outlook 2007 that will automatically save the selected e-mail to a predetermined folder. This is the code I have so far for my macro, but it doesn't work. I get the error Run-time error '91': Object variable or With block variable not set code: Public Sub ExportSAR() Dim TheEmail As MailItem Dim NewFileName As String NewFileName = InputBox("Enter the SaveAs name", "Save E-mail As", "SAR - Change - ") If NewFileName "" Then TheEmail.SaveAs "A:\2009\200907\" & NewFileName, olMSG Else MsgBox "No file name was entered. Operation aborted.", 64, "Cancel Operation" Exit Sub End If End Sub I can't figure out what I need to fix to make this work. Any help would be great. Thanks, Brad |
Ads |
#2
|
|||
|
|||
![]()
Your code needs a statement to instantiate the TheEmail variable. If you
want the item selected in the current folder view, that would be Application.ActiveExplorer.Selection(1). -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Brad" wrote in message ... Thanks for taking the time to read my question. I'd like to make a button on my tool bar in Outlook 2007 that will automatically save the selected e-mail to a predetermined folder. This is the code I have so far for my macro, but it doesn't work. I get the error Run-time error '91': Object variable or With block variable not set code: Public Sub ExportSAR() Dim TheEmail As MailItem Dim NewFileName As String NewFileName = InputBox("Enter the SaveAs name", "Save E-mail As", "SAR - Change - ") If NewFileName "" Then TheEmail.SaveAs "A:\2009\200907\" & NewFileName, olMSG Else MsgBox "No file name was entered. Operation aborted.", 64, "Cancel Operation" Exit Sub End If End Sub I can't figure out what I need to fix to make this work. Any help would be great. Thanks, Brad |
#3
|
|||
|
|||
![]()
Thanks Sue,
I was just lookin at that in the Outlook Developer Reverence - Application Object Model Map. I'll try adding this to my code and see what I get. Brad "Sue Mosher [MVP]" wrote: Your code needs a statement to instantiate the TheEmail variable. If you want the item selected in the current folder view, that would be Application.ActiveExplorer.Selection(1). -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Brad" wrote in message ... Thanks for taking the time to read my question. I'd like to make a button on my tool bar in Outlook 2007 that will automatically save the selected e-mail to a predetermined folder. This is the code I have so far for my macro, but it doesn't work. I get the error Run-time error '91': Object variable or With block variable not set code: Public Sub ExportSAR() Dim TheEmail As MailItem Dim NewFileName As String NewFileName = InputBox("Enter the SaveAs name", "Save E-mail As", "SAR - Change - ") If NewFileName "" Then TheEmail.SaveAs "A:\2009\200907\" & NewFileName, olMSG Else MsgBox "No file name was entered. Operation aborted.", 64, "Cancel Operation" Exit Sub End If End Sub I can't figure out what I need to fix to make this work. Any help would be great. Thanks, Brad |
#4
|
|||
|
|||
![]()
Thanks Sue,
It's working perfectly now. Have a great weekend, Brad "Sue Mosher [MVP]" wrote: Your code needs a statement to instantiate the TheEmail variable. If you want the item selected in the current folder view, that would be Application.ActiveExplorer.Selection(1). -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Brad" wrote in message ... Thanks for taking the time to read my question. I'd like to make a button on my tool bar in Outlook 2007 that will automatically save the selected e-mail to a predetermined folder. This is the code I have so far for my macro, but it doesn't work. I get the error Run-time error '91': Object variable or With block variable not set code: Public Sub ExportSAR() Dim TheEmail As MailItem Dim NewFileName As String NewFileName = InputBox("Enter the SaveAs name", "Save E-mail As", "SAR - Change - ") If NewFileName "" Then TheEmail.SaveAs "A:\2009\200907\" & NewFileName, olMSG Else MsgBox "No file name was entered. Operation aborted.", 64, "Cancel Operation" Exit Sub End If End Sub I can't figure out what I need to fix to make this work. Any help would be great. Thanks, Brad |
#5
|
|||
|
|||
![]()
Would you please help me and let me know how your problem for auto save as *.msg was solved .
Thanks in advance for your cooperation . Brad wrote on Fri, 17 July 2009 15:09 Thanks Sue, It's working perfectly now. Have a great weekend, Brad "Sue Mosher [MVP]" wrote: Your code needs a statement to instantiate the TheEmail variable. If you want the item selected in the current folder view, that would be Application.ActiveExplorer.Selection(1). -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Brad" wrote in message ... Thanks for taking the time to read my question. I'd like to make a button on my tool bar in Outlook 2007 that will automatically save the selected e-mail to a predetermined folder. This is the code I have so far for my macro, but it doesn't work. I get the error Run-time error '91': Object variable or With block variable not set code: Public Sub ExportSAR() Dim TheEmail As MailItem Dim NewFileName As String NewFileName = InputBox("Enter the SaveAs name", "Save E-mail As", "SAR - Change - ") If NewFileName "" Then TheEmail.SaveAs "A:\2009\200907\" & NewFileName, olMSG Else MsgBox "No file name was entered. Operation aborted.", 64, "Cancel Operation" Exit Sub End If End Sub I can't figure out what I need to fix to make this work. Any help would be great. Thanks, Brad |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to save a email, sent out, as a file | DPM | Outlook and VBA | 4 | December 11th 07 05:46 AM |
mshtml.Help file is missing. Can't save E-Mail pictures. | Andy | Outlook Express | 10 | October 18th 07 03:02 AM |
How to automatic save file and forward mail? | Mesak | Outlook and VBA | 1 | July 26th 07 03:54 PM |
outlook 2k3 Script: how to Save Mail body to txt file | news.microsoft.com | Outlook and VBA | 5 | November 7th 06 02:23 PM |
trying to save as .msg file !! | WhytheQ | Outlook and VBA | 2 | May 26th 06 01:32 PM |