View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Tim Li - MSFT Tim Li - MSFT is offline
external usenet poster
 
Posts: 6
Default Hide Ribbon In XLS Workbook When Using Excel 2007

Hello AG,

Yes the workbook would remain Excel 2003 format, and it will works fine in
Excel 2007.

Also it is possible to make the User Form always be visible and we'll be
able to set focus to it, the detailed solution is shows as below:

To make User Form visible at Workbook open we could take use of Workbook
Open event:
Private Sub Workbook_Open()
UserForm1.Show vbModeless
End Sub

To set focus we have two options:
1st. The simple way. We could write a macro as below and assign a shortcut
to the macro.
Sub Setfocus()
UserForm1.Hide
UserForm1.Show vbModeless
End Sub

2nd.This method will need some Windows APIs to achieve the same.
First we need to insert a new class in the VB Editor and paste the
following code into the class.

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As
Long) As Long

Public Sub ActivateUserForm()
SetForegroundWindow DialogHWnd(UserForm1)
End Sub

Public Function DialogHWnd(ByRef WindowObject As Object) As Long
DialogHWnd = GetWindowFromTitle(WindowObject.Caption, "ThunderDFrame")
End Function

Public Function GetWindowFromTitle(ByVal WindowTitle As String, Optional
ByVal ClassName As String) As Long
hwnd = FindWindow(ClassName, WindowTitle)
GetWindowFromTitle = hwnd
End Function

Then we write a macro and assign a shortcut, the same as the first method:
Sub activewindow()
Dim k As New Class1
k.ActivateUserForm
End Sub

Best regards,
Tim Li
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.