Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
I've built a macro that generates a file with a normal extension .xls
But, when I try to open the file after saving it, the following alert appears:
Microsoft Office Excel
The file you are trying to open, 'Report.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the File. Do you want to open the file now?
Above the code.
How can I eliminate the alert?
I've built a macro that generates a file with a normal extension .xls
But, when I try to open the file after saving it, the following alert appears:
Microsoft Office Excel
The file you are trying to open, 'Report.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the File. Do you want to open the file now?
Above the code.
Code:
Dim xMail As Object
Dim Location As String
Dim objWS As Object
Set objWS = CreateObject("WScript.Shell")
Location = objWS.SpecialFolders("Desktop")
Application.DisplayAlerts = False
destinazione.SaveAs Location & "\Report.xls"
destinazione.Close False
Application.DisplayAlerts = True
Set xMail = CreateObject("Outlook.Application").CreateItem(0)
With xMail
.Subject = "Communication"
.Attachments.Add (Location & "\Report.xls")
.Display
End With
How can I eliminate the alert?