View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_2_] Leith Ross[_2_] is offline
external usenet poster
 
Posts: 128
Default Updating ExcelName Registry Key

On Aug 21, 2:27 pm, Don wrote:
I have created an App in Excel that I would like to display the
"Window Caption - MyApp Name" instead MyApp filename and " - Microsoft
Excel" in the Title Bar.

Is there a way to update the "HKEY_CURRENT_USER\Software\Microsoft
\Office\12.0\Excel\ExcelName" registry key everytime the app opens?

I can't even manually set it in the regitsry and open Excel. The key
automatically resets to "Microsoft Excel" after the file loads.
Thanks!


Hello Don,

You can "brand" Excel using a few API calls. Place these in a Standard
VBA Module.

'This will be used to find the Window to Excel
Public Declare Function FindWindow _
Lib "user32.dll" _
Alias "FindWindowA" _
(ByVal lpszClass As String, _
ByVal lpszWindow As String) As Long

'This will be used to change the Window Caption
Private Declare Function SetWindowText _
Lib "user32.dll" _
Alias "SetWindowTextA" _
(ByVal hWnd As Long, _
ByVal lpszBuffer As String) As Long

Public Sub BrandExcel()
Dim NewTitle As String
Dim hWnd As Long
Dim Retval
' Change NewTitle to what you want
NewTitle = "Book 1"
' Returns zero if function fails
hWnd = FindWindow("XLMAIN", vbNullString)
' Return 1 if title was changed
Retval = SetWindowText(hWnd, NewTitle)
End Sub

Sincerely,
Leith Ross