只有userform应该是可见的而不是excel

时间:2015-07-13 10:34:34

标签: excel-vba vba excel

请告知我们如何仅显示userform而不是在其背后擅长。

我使用application.visible = false,但它隐藏了所有其他excel。 我使用了activatewindow.visible = false,但userform没有从excel中检索数据。 我使用activatewindow.displayworkbooktabs=false但它没有隐藏工作簿。

2 个答案:

答案 0 :(得分:0)

试试这段代码。

Private Sub Workbook_Open()
    Application.Visible = False
    UserForm1.Show vbModeless
End Sub

不要忘记在关闭之前使应用程序可见

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    Application.Visible = True
End Sub

答案 1 :(得分:0)

将此内容写入userform:

Private Sub CommandButton1_Click()
  Dim wCount  As Long
  Dim i       As Long

  wCount = Windows.Count
  For i = 1 To wCount
    Windows(i).Visible = True
  Next i

  Unload Me
End Sub

Private Sub UserForm_Initialize()
  Dim wCount  As Long
  Dim i       As Long

  wCount = Windows.Count
  For i = wCount To 1 Step -1
    Windows(i).Visible = False
  Next i

End Sub