当前代码:
Sub CreateFormsButton()
Dim ws As Worksheet
Dim btn As Button
Dim rng As Range
Dim counter As String
counter = 6
For Each ws In ThisWorkbook.Worksheets
If ws.Name = "Navigation" Or ws.Name = "Todo" Then
Else
With ws
Set rng = ThisWorkbook.Sheets("Navigation").Range("C" + CStr(counter))
Set btn = .Buttons.Add(rng.Left, rng.Top, rng.Width, rng.Height * 2)
With btn
.Caption = ws.Name
.OnAction = "GoToWS"
.Font.Bold = True
.Font.Size = 16
End With
End With
End If
counter = counter + 2
Next ws
End Sub
代码排序按原样工作,然而,按钮被放置在工作表本身而不是预期的导航工作表上。我是否通过设置Set rng = ThisWorkbook.Sheets("Navigation").Range("C" + CStr(counter))
做错了什么?这似乎对按钮的放置位置没有任何影响。谢谢你的帮助。
答案 0 :(得分:1)
您需要在导航表的按钮集合中添加按钮。
indices=....