Hello! First time here.
I'm having some issues trying to add checkboxes in multiple workbooks. I created a loop to work throught all files in a specific folder, but it only works on the first file and when it goes to the next one, i get error 438, for the Caption and LinkedCell functions on my code. Hope someone can help!
Obs: The problem really is with the checkbox creation and definition of its parameters. I tried the code with different simple actions like defining cell values and it works perfectly.
Code
Sub LoopThroughFiles()
folderName = "C:\******"
If Right(folderName, 1) <> Application.PathSeparator Then folderName = folderName & Application.PathSeparator
Fname = Dir(folderName & "*.xlsx")
'loop through the files
Do While Len(Fname)
With Workbooks.Open(folderName & Fname)
Sheets("Orçamento").CheckBoxes.Add(Left:=Range("L12").Left, Top:=Range("L12").Top, Width:=Range("Y12").Width, Height:=Range("L12").Height).Select
With Selection
.Caption = ""
.LinkedCell = "Parâmetros!A" & 27
End With
End With
ActiveWorkbook.Close savechanges:=True
' go to the next file in the folder
Fname = Dir
Loop
End Sub
Display More
Thanks for the attention!