Formatting a Path string...

J

Jeff Rush

Hi All,
I am having problems with the following code I believe because I am not
encapsulting the Path String in Quotes. However I am not sure how to do it
in VBA...

Any Help would be greatly appreciated..

Thx,

Jeff

====================================================

Sub ChngForamt()

Dim olMsg As Object
Dim SavePath As String

SavePath = "C:\MyTestFolder\"

'Set variable to the (collection of) selected items in Inbox.
Set myolsel = Application.ActiveExplorer.Selection

For Each olMsg In myolsel
SavePath = SavePath & (RTrim(LTrim(olMsg.Subject))) & "RTF"
MsgBox ("SavePath = " & SavePath)
Select Case (olMsg.BodyFormat)

Case olFormatHTML:
olMsg.BodyFormat = olFormatRichText
olMsg.SaveAs
Case olFormatPlain:
olMsg.BodyFormat = olFormatRichText
olMsg.SaveAs SavePath, olRTF
Case olFormatUnspecified:
olMsg.BodyFormat = olFormatRichText
olMsg.SaveAs SavePath, olRTF
Case olFormatRichText
olMsg.SaveAs SavePath
End Select
SavePath = "C:\MyTestFolder\"
Next


End Sub
 
S

Sue Mosher [MVP]

What problems are you having? I don't see anything in particular amiss, other than no check for existing items with the same file name.
--
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
 
J

Jeff Rush

Hi Sue,

If there is a space in the subject it truncates the Filename at the space.
IE Subject = "Hi Jeff" the path ends up being C:\MyTestFolder\Hi

My thought was that encapsulating it in double quotes in the string so it
would be
"C:\MyTestFolder\Hi Jeff.rtf" would fix this. However, I put the subject in
a parsing loop to omit spaces and special chars (@, !, : etc..) fixed the
issue.

NOW I have ANOTHER problem. The Plain Text files are saved fine, the HTML
files are saved fine but the RTF (WordMail) docs are garbled....

Any thoughts??

TYIA!!!

Jeff


What problems are you having? I don't see anything in particular amiss,
other than no check for existing items with the same file name.
--
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
 
J

Jeff Rush

Same Code, new problem. :)
I now have it saving by using a for loop to loop through the subject and
removing special chars :), ;, ! etc) and replacing a space with an
underscore. Now the files are saving with an RTF extension. The HTML,
Unspecified (I believe) and Plain Text are doing fine. However the mail
that is coming in as Rich text or from WordMail are garbled. When I try to
open them I get the option in word to select the encoding format ASCII,
Western European etc.

I just don't understand it... I even removed the olRTF from the save as
statement thinking it may be forcing some sort of format change. Still no
dice.

Any thoughts??

What problems are you having? I don't see anything in particular amiss,
other than no check for existing items with the same file name.
--
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
 
S

Sue Mosher [MVP]

What do you mean by garbled?
--
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
 
R

Rick Andrews

Jeff, wanted to say thanks for posting the code snippet. It helped me solve one of my own problems unrelated to yours :) Good luck.
 

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