运行Windows 10,Excel2013。我有第二个以扩展模式运行的监视器。我正在尝试自动在VBA中打开第二个窗口,将工作表拖到第二个监视器,然后在主监视器上显示另一个工作表。不管成功与否,都是命中注定的。有时候会,有时候不会。我在做什么错了?
Sub Setup_The_Raffle()
'
' Setup_The_Raffle Macro
'
' Open a new window
' Open the Tote_Board sheet
' Restore down the window
' Shift it to the other screen
' Maximize it
' Turn off gridlines, headings, and the formula bar
' Autohide the menu
' Switch back to the original window
' Open the "Sequence of Pulled Tickets" sheet
ActiveWindow.NewWindow
Sheets("Tote_Board").Select
Sheets("Tote_Board").Activate
Application.WindowState = xlNormal
Application.Left = 1000
Application.WindowState = xlMaximized
Dim wsSheet As Worksheet
Application.ScreenUpdating = False
For Each wsSheet In ThisWorkbook.Worksheets
If wsSheet.Name = "Tote_Board" Then
wsSheet.Activate
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayWorkbookTabs = False
CommandBars.ExecuteMso "HideRibbon"
End With
End If
Next wsSheet
ActiveWindow.ActivatePrevious
Sheets("Sequence of Pulled Tickets").Activate
End Sub