Active workbook attaching as a zip file, not .xls

Matt Salas

New Member
Joined
Jan 8, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
First time posting, so I hope I'm doing it right. I have a macro to copy 2 specific pages from a macro-enabled workbook, prompt the user to save the workbook in a file location with a specific name from referenced cells within the new workbook and attached the new active workbook to an email. However, the file is attached as a .zip file, not .xls. What am I doing wrong?

Code:

fname = Application.GetSaveAsFilename(InitialFileName:="VAR Qualification form for " & Range("B8").Value & "," & " LT# " & ThisWorkbook.Sheets("VAR Information").Range("C2").Value, fileFilter:="Excel Files (*.xlsx), *.xlsx", Title:="Save As")
If fname = False Then Exit Sub
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fname, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

StrBody = "<BODY style=font-size:12pt;font-family:calibri><font color=334d99>Hello,<br><br>Will you please process the attached VAR qualification form? Thanks!!"

Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)

With OutlookMail

.Display
.To = "test@@test.com"
.CC = ""
.BCC = ""
.Subject = "VAR qualification for " & ThisWorkbook.Sheets("VAR Information").Range("B8").Value & "," & " LT# " & ThisWorkbook.Sheets("VAR Information").Range("C2").Value
.HTMLBody = StrBody & .HTMLBody
.Attachments.Add ActiveWorkbook.FullName
End With

Application.DisplayAlerts = True
ActiveWorkbook.Close False


End Sub

I've tried a simpler form of the macro just sending an active workbook with the same results, leading me to believe isn't a security setting of some sort rather that an issue with the macro

Code:
Sub SendWorkBook()
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
On Error Resume Next
With OutlookMail
.Display
.To = "test@extendoffice.com"
.CC = ""
.BCC = ""
.Subject = "VAR qualification for " & ThisWorkbook.Sheets("VAR Information").Range("B8").Value & "," & " LT# " & ThisWorkbook.Sheets("VAR Information").Range("C2").Value
.Body = "Hello, please check and read this document, thank you."
.Attachments.Add Application.ActiveWorkbook.FullName
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
1,830
Office Version
  1. 365
Platform
  1. Windows
So on first blush I don't see anything wrong. I ran the SendWorkbook code and was able to attach a .xlsx file. Maybe your I/T dept. has an outlook addon loaded.
 

Matt Salas

New Member
Joined
Jan 8, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
So on first blush I don't see anything wrong. I ran the SendWorkbook code and was able to attach a .xlsx file. Maybe your I/T dept. has an outlook addon loaded.
Hi Jeffrey - That's what I thought, but it's happening on 3 different machines I have and with other users as well. Do you have any idea what add-in from outlook would be preventing this?
 

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
1,830
Office Version
  1. 365
Platform
  1. Windows
Not particularly. You can see the loaded Add-ins though. In Outlook click on File - Options - Add-Ins - The GO button (next to Mange: COM Add-ins)

You may be able to disable them if they will let you.
 

Attachments

  • 1610137754022.png
    1610137754022.png
    25 KB · Views: 2

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
1,830
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

When you manually add a file as an attachment, do you get the same thing?
 

Watch MrExcel Video

Forum statistics

Threads
1,130,129
Messages
5,640,296
Members
417,135
Latest member
zeusmining

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top