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.
Bookmarks