Hello Everyone,
I need help with VBA coding... I will definitely appreciate all of your suggestions. :)
* I'm not an expert on this, I only follow a lot of youtube tutorials. *
I need to remove a specific shape under my Macro-Enabled Workbook.
What I want is when I click on "Add to Database" button, the active workbook will be saved as a new workbook on a specific path and filename as .xlsx
under the image below I encircled those Buttons that I need to remove, however, I only have a code that will remove all the shapes under my worksheet, including my logo photo, checkboxes, and text box...
Here's the code:
Sub Recordofjobcards()
Dim jobcardno As String
Dim dateissued As Date
Dim Custname As String
Dim phoneno As String
Dim amt As Currency
Dim nextrec As Range
jobcardno = Range("b7")
dateissued = Range("H7")
Custname = Range("c9")
phoneno = Range("c11")
amt = Range("G17")
fname = jobcardno
Set nextrec = Sheet3.Range("A1048576").End(xlUp).Offset(1, 0)
nextrec = jobcardno
nextrec.Offset(0, 1) = dateissued
nextrec.Offset(0, 2) = Custname
nextrec.Offset(0, 3) = phoneno
nextrec.Offset(0, 4) = amt
path = "C:\Users\LENOVO\OneDrive\LOSH CARS 2023\Job Cards\June.XLSX"
'copy the jobcard sheet to a new workbook
Sheet2.Copy
'then delete command buttons on the worksheet
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
shp.Delete
Next shp
'save the new workbook to a specified folder
With ActiveWorkbook
.Sheets(1).Name = "jobcard"
.SaveAs Filename:=path & fname, FileFormat:=51
.Close
End With
'need to put the details of the jobcard in the record of jobcards sheet
Sheet3.Hyperlinks.Add anchor:=nextrec.Offset(0, 7), Address:=path & fname & ".xlsx"
path = "C:\Users\LENOVO\OneDrive\LOSH CARS 2023\Job Cards\June\PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, ignoreprintareas:=False, Filename:=path & fname
Sheet3.Hyperlinks.Add anchor:=nextrec.Offset(0, 6), Address:=path & fname & ".pdf"
End Sub
Only those buttons (form button) that I want to remove.
[![](https://learn-attachment.microsoft.com/api/attachments/3d4bd865-8bc9-4358-8a81-e3339df9d0f0?platform=QnA