+ Reply to Thread
Results 1 to 2 of 2

macro function not found?

Hybrid View

okl macro function not found? 02-02-2010, 06:34 AM
romperstomper Re: macro function not found? 02-02-2010, 06:47 AM
  1. #1
    Forum Contributor
    Join Date
    01-17-2008
    Posts
    156

    macro function not found?

    excel prompt macro function Save_Exit() not found ?
    Sub Workbook_Open()
    
    ' Don't forget to copy the function RangetoHTML in the module.
    ' Working in Office 2000-2007
        Dim rng As Range
        Dim OutApp As Object
        Dim OutMail As Object
        Dim SafeItem As Object
        
        With Application
            .EnableEvents = False
            .ScreenUpdating = False
        End With
     
        Set rng = Nothing
        Set rng = ActiveSheet.UsedRange
        'You can also use a sheet name
        'Set rng = Sheets("YourSheet").UsedRange
    
        Set OutApp = CreateObject("Outlook.Application")
        Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
      
        
        OutApp.Session.Logon
        Set OutMail = OutApp.CreateItem(0)
      SafeItem.Item = OutMail 'set Item property
    SafeItem.Recipients.Add "ongkokl@psa.com.sg"
    SafeItem.Recipients.ResolveAll
    
        On Error Resume Next
        With SafeItem
            .To = "ongkokl@psa.com.sg"
            .CC = ""
            .BCC = ""
            .Subject = "BT Direct Disc " & Format(Now, "dd-mmm-yy hh:mm")
            .HTMLBody = RangetoHTML(rng)
            .Send   'or use .Display
        End With
        On Error GoTo 0
     
        With Application
            .EnableEvents = True
            .ScreenUpdating = True
        End With
     
        Set OutMail = Nothing
        Set OutApp = Nothing
    
    Application.OnTime Now + TimeValue("00:0:05"), "Save_Exit"
    
    End Sub
    
    Sub Save_Exit()
      Application.Quit
      ThisWorkbook.Close SaveChanges:=True
    End Sub
    Attached Images Attached Images
    Last edited by okl; 02-02-2010 at 07:07 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: macro function not found?

    Your Save_Exit code needs to be in a normal module, not in the ThisWorkbook module.
    Everyone who confuses correlation and causation ends up dead.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1