Hi Jim,
Thanks for the reply! Yes it happens on all of our Macs with Excel 2016 installed. Excel is fairly up to date. Version 15.31 (170216) is what we have installed.
I just tried running only this portion of the macro in a new spreadsheet and it worked. I'm not sure why the context of the rest of my macro is causing this to fail, it's quite baffling as there's really nothing that comes before this portion besides a copy
/ paste that sets up the text that the Buttons.Add is looking for.
Here's the entire code from my macro that fails every time at the first ".Caption" section:
Sub new_spot()
'Go to the Template sheet and copy rows 1-9
With Worksheets("Template")
.Visible = False
.Rows("2:12").Copy
End With
'Variables
Dim numb As Integer
numb = Worksheets("Template").Range("B15").Value
'Check to see if there is already 100 graphics, and end if there is
If numb > 100 Then
MsgBox "You have exceeded the number of allowable graphics. Please start a new tracker. :)"
End
End If
'Select the GFX sheet
Sheets("GFX").Select
'Go to the last cell in row B and start 2 from the last blank cell
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select
'This pastes the sections from the template to the GFX sheet
Rows(Selection.Row).PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
, SkipBlanks:=False, Transpose:=False
'Variables
Dim r As Range
Dim verline As String
verline = "ver_line_" & numb
Dim newasset As String
newasset = "new_asset_" & numb
Dim addimg As String
addimg = "add_img_" & numb
Dim newgraph As String
newgraph = "new_graph_" & numb
For Each r In Range("T:T")
'This will add the "New Version" button
If r.Value Like verline Then
With r.Parent.Buttons.Add(r.Left, r.Top, r.Width, r.Height)
.Font.Bold = True
.Caption = "New Version"
.OnAction = "new_version" & numb
End With
End If
Next r
'This will add the "New Asset" button
For Each r In Range("T:T")
If r.Value Like newasset Then
With r.Parent.Buttons.Add(r.Left, r.Top, r.Width, r.Height)
.Font.Bold = True
.Caption = "New Asset"
.OnAction = "new_asset" & numb
End With
End If
Next r
For Each r In Range("T:T")
'This will add the "New Graphic" button
If r.Value Like newgraph Then
With r.Parent.Buttons.Add(r.Left, r.Top, r.Width, r.Height)
.Font.Bold = True
.Caption = "New Graphic"
.OnAction = "new_graph" & numb
End With
End If
Next r
'Then we need to go back to the template and increase the integer by one on all the variables, so the macro knows to use the next sequence
Worksheets("Template").Range("B15").Value = numb + 1
numb = Worksheets("Template").Range("B15").Value
Worksheets("Template").Range("T7").Value = "ver_line_" & numb
Worksheets("Template").Range("T9").Value = "new_asset_" & numb
Worksheets("Template").Range("T12").Value = "new_graph_" & numb
Worksheets("Template").Range("A12").Value = "last_line_" & numb
End Sub