msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Newbie "save post item as .." Can't get it to work.

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> MS Office Outlook
Author Message
Marceepoo



Joined: 13 Aug 2007
Posts: 7

PostPosted: Thu Jan 24, 2008 2:02 pm    Post subject: Newbie "save post item as .." Can't get it to work. Reply with quote

I can't get this macro to work. i'm trying to save the email item that is open
to a file. I'm trying two alternatives, i.e., save to .txt and save to .html

Nothing gets saved, when I use the code line below ("objItem.SaveAs strname
& ".txt", olTXT") and I input "e:\Harvey" to the inputbox.

But when I use the code line below ("objItem.SaveAs strname & ".html",
olHTML), I get an error message: "Invalid procedure call or argument" and
the debugger highlights the line: "objItem.SaveAs strname & ".html", olHTML

Questions:
1. What am I doing wrong?
2. Where can I learn more about the issues I'm missing?

Thanks,
marceepoo


Sub SaveCurrentEmailItemAsTxtOrHtml()
'
'Cannibalized from:
http://msdn2.microsoft.com/en-us/library/bb175460(printer).aspx
'

Dim myItem As Outlook.Inspector
Dim objItem As Object
Dim strname, strPrompt, strUserInput As String

Set myItem = Application.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem
strname = objItem.Subject
'Prompt the user for confirmation
strPrompt = "Are you sure you want to save the item? " & _
"If a file with the same name already exists, " & _
"it will be overwritten with this copy of the file." & vbCrLf & _
" If you want to save it, input here the full path and file name,
" & _
"w/o quotation marks, and w/o the '.htm' extension: "
strUserInput = InputBox(strPrompt, "Save Email to File (HTML)", "")
objItem.SaveAs strname & ".txt", olTXT
' objItem.SaveAs strname & ".html", olHTML
Else
MsgBox "There is no current active inspector."
End If
End Sub

Archived from group: microsoft>public>office>developer>outlook>vba
Back to top
View user's profile Send private message
Michael Bauer [MVP - Outl



Joined: 12 Aug 2007
Posts: 92

PostPosted: Fri Jan 25, 2008 1:03 pm    Post subject: Re: Newbie "save post item as .." Can't get it to work. Reply with quote

SaveAs exptects that the directory already exists.

--
Best regards
Michael Bauer - MVP Outlook
Synchronize Outlook Categories:


Am Thu, 24 Jan 2008 09:02:03 -0800 schrieb Marceepoo:

> I can't get this macro to work. i'm trying to save the email item that is
open
> to a file. I'm trying two alternatives, i.e., save to .txt and save to
..html
>
> Nothing gets saved, when I use the code line below ("objItem.SaveAs
strname
> & ".txt", olTXT") and I input "e:\Harvey" to the inputbox.
>
> But when I use the code line below ("objItem.SaveAs strname & ".html",
> olHTML), I get an error message: "Invalid procedure call or argument" and
> the debugger highlights the line: "objItem.SaveAs strname & ".html",
olHTML
>
> Questions:
> 1. What am I doing wrong?
> 2. Where can I learn more about the issues I'm missing?
>
> Thanks,
> marceepoo
>
>
> Sub SaveCurrentEmailItemAsTxtOrHtml()
> '
> 'Cannibalized from:
> http://msdn2.microsoft.com/en-us/library/bb175460(printer).aspx
> '
>
> Dim myItem As Outlook.Inspector
> Dim objItem As Object
> Dim strname, strPrompt, strUserInput As String
>
> Set myItem = Application.ActiveInspector
> If Not TypeName(myItem) = "Nothing" Then
> Set objItem = myItem.CurrentItem
> strname = objItem.Subject
> 'Prompt the user for confirmation
> strPrompt = "Are you sure you want to save the item? " & _
> "If a file with the same name already exists, " & _
> "it will be overwritten with this copy of the file." & vbCrLf & _
> " If you want to save it, input here the full path and file
name,
> " & _
> "w/o quotation marks, and w/o the '.htm' extension: "
> strUserInput = InputBox(strPrompt, "Save Email to File (HTML)",
"")
> objItem.SaveAs strname & ".txt", olTXT
> ' objItem.SaveAs strname & ".html", olHTML
> Else
> MsgBox "There is no current active inspector."
> End If
> End Sub

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Delete a post from this newsgroup? How does one delete a posting from this newsgroup? I recently posted a question and stupidly listed my name and email address, foolishly assuming only people of integrity used this forum. Instead, I have been swamped with Spam that purports to be from Mi

help for get the parent item id help for get the parent item id, how can i get the parent mailitem for reply?

How to get the mail item? Hi, I need to get all the mail items from Outlook in VB. Can any one assist me. Thank you. jai

Hoe to set the sender name of a mail Item Hi, I create a mailItem and I have to set its sender name but this property is readonly. How can I set this ? myOlApp=new mailItem; = "Fred"; Thanks, David

Add item to default calendar Using Office 2003 and Windows XP; From VBA (in Excel) I would like to add an item to the default calendar. This item should have: * all day event = false * the same start and end date and time; * busy status = not busy; * no reminder; This is what I have
Post new topic   Reply to topic    msoutlook.org Forum Index -> MS Office Outlook All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group