Results 1 to 6 of 6

Send Workbook as Attachment

Threaded View

  1. #1
    Registered User
    Join Date
    10-06-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    23

    Send Workbook as Attachment

    Hi Gurus,

    I have a workbook that needs to be sent as attachment on the click of a button but the following section of the code that caters for this macro gives me error on some of the computers in the office, and completely fine on others. The error is "TempWB.FullName = <Object variable or With block variable not set>". Here is the section that should get you into context:

    'House Keeping
        Dim oApp As Object
        Dim oMail As Object
        Dim TempFilePath As String
        Dim TempWB As Workbook
    
        Application.ScreenUpdating = False
    
    'Enter Read Mode
        Call EnterReadMode
         
    'Create a new temporary folder on M: drive and save attachment there
        On Error Resume Next
        MkDir "M:\User Admin"
        TempFilePath = "M:\User Admin\"
        ActiveWorkbook.SaveCopyAs TempFilePath & strAttachmentName
        Set TempWB = Workbooks.Open(TempFilePath & strAttachmentName)
        On Error GoTo 0
        
    'Create and send the outlook mail item
    
        If Worksheets("Approval").Range("E13") = "" Then
        
            Set oApp = CreateObject("Outlook.Application")
            Set oMail = oApp.CreateItem(0)
            With oMail
                .To = strApprover
                .Subject = "User Administration Approval Required"
                .Attachments.Add TempWB.FullName
                .Body = "Dear " & strApprover & "," & vbCrLf & vbCrLf _
                    & "There is a user administrative request that requires your approval. " _
                    & "Please see the attached User Admin Form." & vbCrLf & vbCrLf _
                    & "Regards," & vbCrLf _
                    & strSender
                .Display
            End With
    End If
    Can you help?
    Thanks guys.
    Last edited by amdk8800; 05-14-2010 at 01:11 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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