troubleshooting Question

Delete VBA Macro Code

Avatar of freejaso
freejaso asked on
Visual Basic Classic
9 Comments1 Solution894 ViewsLast Modified:
I have an XLS file that has some VBA code to send an outlook message with the attached file. I save the XLS file to a new name, hide the cmd button the user pressed to send the message and then attach the file BUT I need to delete the VBA code so that when the client opens the XLS file they do not the the warning about macros. Can someone please help?

Private Sub SendEmail_Click()

    Dim objOL As New Outlook.Application
    Dim objMail As MailItem
    Set objOL = New Outlook.Application
    Set objMail = objOL.CreateItem(olMailItem)
    Dim objXLS As Excel.Workbook
    Set objXLS = Excel.ThisWorkbook
    'Save workbook
    objXLS.SaveAs Sheet2.Range("B6")
    SendEmail.Visible = False

   **********Delete macro, THIS IS WHERE I AM STUCK!!

    With objMail
        .To = Sheet2.Range("B1")
        .CC = Sheet2.Range("B2")
        .BCC = Sheet2.Range("B3")
        .Subject = Sheet2.Range("B4")
        .Body = Sheet2.Range("B5")
    End With
Set objMail = Nothing
Set objOL = Nothing

End Sub


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros