Hello,
I am trying to replace the caption of an Excel workbook with a custom caption. I've used application.caption = "custom caption" but this only adds my custom caption it doesn't remove the file name. I found the following code:
Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText _
Lib "user32" Alias "SetWindowTextA" _
(ByVal hwnd As Long, _
ByVal lpString As String) As Long
Sub AlterExcelCaption(strCaption As String)
SetWindowText FindWindow("XLMAIN", Application.Caption), strCaption
End Sub
Sub test()
AlterExcelCaption "Just testing"
End Sub
This code works in Excel03 but not in 07. I think the problem is with "XLMAIN". Is there someone who can help me?
Thank you in advance.
I am trying to replace the caption of an Excel workbook with a custom caption. I've used application.caption = "custom caption" but this only adds my custom caption it doesn't remove the file name. I found the following code:
Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText _
Lib "user32" Alias "SetWindowTextA" _
(ByVal hwnd As Long, _
ByVal lpString As String) As Long
Sub AlterExcelCaption(strCaption As String)
SetWindowText FindWindow("XLMAIN", Application.Caption), strCaption
End Sub
Sub test()
AlterExcelCaption "Just testing"
End Sub
This code works in Excel03 but not in 07. I think the problem is with "XLMAIN". Is there someone who can help me?
Thank you in advance.