Results 1 to 13 of 13
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Austin, Texas
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro needed to save msg as .rtf! (2000)

    Help. I'm new to this macro creation thing using VBA in Outlook 2K. I've updated a user to Outlook 2K from '97. She needs to save received Emails (no matter what format they came in) as.rtf by default to a specific network directory. I've received some help on this - where the code allows the save as .rtf only if the originating format was .rtf, and no choice on where to go from the default directory. Ultimately, what I need to see after running the macro is the Save As dialog box sitting there at the default directory, in .rtf format, and the user can browse to a subfolder and name the Email message according to the schemes they have utilized - i.e., Msg to Joe Smith-23. This means hacking the file name themself from the default (I believe the subject line?) , but I think they already were used to doing this in Outlook 97. The user needs to see what has been saved before in the chosen (sub)directory so they can keep the file-naming scheme going. I've attached a text file of the existing macro.
    So, am I crazy? Thanks everyone!
    Kim Caldwell, Austin, Texas
    Attached Files Attached Files

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    Well, there's this:

    Sub SaveAs()

    Dim cbtnSAF As CommandBarButton

    Set cbtnSAF = ActiveInspector.CommandBars.FindControl(, 748)
    cbtnSAF.Execute

    End Sub
    -John ... I float in liquid gardens
    UTC -7DS

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    There is the another issue in that the SaveAs routine seems to choke on .rtf format - .txt and .htm being the only practicable options. (Online Help would make you think otherwise.) This is on SR1 with and without the security update.
    Can you give me a link for other index numbers using FindControl? A limited search on the MSKB and the Immediate Window yields little.
    Gre

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    I used Jefferson's code <!post=here,105614>here<!/post>.
    -John ... I float in liquid gardens
    UTC -7DS

  5. #5
    New Lounger
    Join Date
    Mar 2002
    Location
    Austin, Texas
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    John - I tried your code - as is with no other lines in the macro. It works to save the message, but it still defaults to the default directory and only will save the message in the format the message came in as. I don't know much about this as you can tell. Are your lines meant to be placed in the macro in addition to or replacing some of what I already had? If they are, I need to know where. I still need the macro to save as .rtf no matter what format and save to a net work directory, not Outlook's default.

    Many thanks!

  6. #6
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    RTF appears to be supported as a Save As format, but it appears that the only formats you can switch a message to are HTML and Plain Text. Also, it does appear that you can't automate a change in format. (You have to do it manually in the dialog box.) You may be able to achieve the RTF format as default by using VBScript but that would mean foregoing the browse dialog.
    Adding further lines of code (for format or target directory) to JohnBF's Post does not change the result. Regrettably, the Outlook VBA Object Model is nowhere near as flexible as that available in the other standard MS Office programs. As you have noticed, the subject line of the Message is the default Save As title.
    Changing the Save As default directory seems only possible by changing the location of your My Documents folder. A workaround would be to put a shortcut to the target network folder into the My Documents folder for one-click navigation.
    HTH
    Gre

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    There is some VBA code at Slipstick that changes an HTML message to RTF to purge out potentially nasty active content. I think it did this by doing something with the .Body property or .HTMLbody of the message (long time since I looked at it). I don't know what effect it would have on a plain text message or whether there is a back door way to manipulate that into an RTF format.

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    Kim, I hope you have read the comments from Unkamunca and JScher2000. The best I can do is as follows, and it requires that the message be opened, it uses the last used path instead of the default you wanted to specify, and it re-saves HTML e-mail as text (and of course leaves text and RTF be). Also, and I'm not clear on this, it may fail if Word is the Outlook Editor. It isn't much better than the built-in menu; maybe it's worse!

    Sub SaveAs()
    Dim objMailItem As Object
    Dim cbtnSvAs As CommandBarButton
    ' check for valid open mailitem
    On Error Resume Next
    Set objMailItem = ActiveInspector.CurrentItem
    If Err.Number Or TypeName(objMailItem) <> "MailItem" Then
    Beep
    MsgBox "No mail item is selected, or" & _
    vbLf & "an unknown error has occurred.", vbExclamation
    Exit Sub
    End If
    ' save as text if HTML
    If objMailItem.HTMLBody <> vbNullString Then
    objMailItem.Body = objMailItem.Body
    objMailItem.Save
    End If
    ' pop up file save dialog
    Set cbtnSvAs = ActiveInspector.CommandBars.FindControl(, 748)
    cbtnSvAs.Execute
    ' clear objects
    Set cbtnSvAs = Nothing
    Set objMailItem = Nothing
    End Sub

    Maybe someone with more skill than me can get into File System Objects and get what you want.
    -John ... I float in liquid gardens
    UTC -7DS

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    Do you think the ChDir command will work if called before the dialog? I haven't used it forever, so...

    <big>ChDir Statement</big>

    Changes the current directory or folder.

    Syntax

    ChDir path

    The required path argument is a string expression that identifies which directory or folder becomes the new default directory or folder. The path may include the drive. If no drive is specified, ChDir changes the default directory or folder on the current drive.

    Remarks

    The ChDir statement changes the default directory but not the default drive. For example, if the default drive is C, the following statement changes the default directory on drive D, but C remains the default drive:

    ChDir "D:TMP"

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    I tried it and didn't get the desired result: the "Outlook last used save-as file location" has to be different from the current file system directory. Bother. I have taken this one as far as my limited knowledge will let me.
    -John ... I float in liquid gardens
    UTC -7DS

  11. #11
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    Kim! You decided to post here....great! I'm following the suggestions everyone has made. After working on this last week, I began to get bugged about not being able to figure it out!

    klyjen (from lawnet)

  12. #12
    New Lounger
    Join Date
    Mar 2002
    Location
    Austin, Texas
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    Hey there! All of you are way ahead of me. I'm still sorting through all the answers. I must say I'm very impressed, and wish I could contribute more to the discussion...<font color=6495ed><big>;>)</big></font color=6495ed>

    How did you all learn this? If I had to buy one book, would it be (a) worth it? and ([img]/forums/images/smilies/cool.gif[/img] even possible?

  13. #13
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro needed to save msg as .rtf! (2000)

    edited by unkamunka 2nd April 2002 to clarify which JohnBF code was meant

    Well, Jefferson, the Slipstick code works a treat - <big>as long as</big> you're in Corporate Workgroup Mode! With the Internet Mode Only code, even though I have the recommended CDO installed, it choked on several of the declarations both on an IMO setup and on the CW setup. On an IMO setup, the CW code (which supposedly CAN work on both) produced nothing either. (YMMV as the IMO setup I tested had the Security Update.) From the sound of it, however, kimc has Corporate Workgroup installed.

    On the Word as email editor aspect, the only factor there is that it defaults to Doc format, BUT RTF is also available - which it is not when the Slipstick code is not used. It's just a matter of changing the format in the dialog box. So, as long as kimc clicks on the Slipstick link (above) and inserts both that and JohnBF's <big>first</big> code into the VBAProject.OTM module, she/he should be most of the way there.
    Gre

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •