Results 1 to 2 of 2

Thread: Word / Outlook Macro Issue

  1. #1
    New Member
    Join Date
    Mar 12
    Posts
    3

    Exclamation Word / Outlook Macro Issue

    I posted on this forum quite some time ago about a problem with this macro (below). Thanks to everyone who responded - moving "doc.close" right to the end of the code fixed the problem

    I now have a new problem which is being almost as annoying as the last - the "importance" of emails being sent with the macro is always coming up as low importance. I need the emails to automatically be normal importance. This used to work fine - I have no idea why it doesn't any more. We've been living with it for a while, but a new staff member seems unable to untick the low importance option, so we now really need to resolve this.

    NOTE: The aim of the macro is to allow the user to email a link for a word document (saved on our shared network folder) to another person in the office (we had a lot of trouble with people attaching files to emails and not saving them properly). When a button is pressed, the macro saves and closes the document, and then opens up a new email message in outlook with the link ready to send.

    Some more info that might be helpful:

    • The macro is now in a global template on our shared network drive, however this problem also occurred when it was stored locally on each computer.
    • I have tried changing .Importance from "1" to "olImportanceNormal". It makes no difference.
    • I have tried changing .Importance to "2" and "olImportanceHigh". When I did this, the first time I tried to use the macro, the email came up as high importance, but then all further emails came up as low importance.
    • The problem doesn't seem to be specific to a particular user, computer, template or version of word.


    Does anyone have any ideas why this isn't working and how I might fix it?

    Please note I'm not great at writing macros, so please make any replies as easy to understand as possible!!!

    Thanks in advance for your help

    Sub eMailActiveDocument()

    Dim OL As Object
    Dim EmailItem As Object
    Dim Doc As Document
    Dim DisplayMessage As Boolean
    Dim Test1 As String
    Dim Response1 As VbMsgBoxResult
    Dim Response2 As VbMsgBoxResult
    Dim Saved As Boolean


    Test1 = ActiveDocument.FullName

    Application.ScreenUpdating = False
    Set OL = CreateObject("Outlook.Application")
    Set EmailItem = OL.CreateItem(olMailItem)
    Set Doc = ActiveDocument



    Response2 = MsgBox("The Document must be saved and closed before it can be opened by another user. Would you like to do this now?", vbYesNoCancel, "Save & Close?")

    If Response2 = vbCancel Then Exit Sub
    If Response2 = vbYes Then
    Doc.Save
    Test1 = ActiveDocument.FullName
    End If


    With EmailItem
    .Importance = 1
    .HTMLBody = "<HTML><BODY><A href=""" & Test1 & """>""" & Test1 & """</A> </BODY></HTML>"

    End With



    Application.ScreenUpdating = True

    EmailItem.Display
    Doc.Close
    End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,528

    Re: Word / Outlook Macro Issue

    possibly cause could be the olMailItem is not in scope, so ol.createitem is using the default, try to declare the constant or use literal value, though i would believe that 0 would be the default anyway

    what happens to the importance if you send the email from the code?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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