PDA

View Full Version : Changing Window name



Thymen
03-12-2006, 02:00 AM
Hi folks,

when Excel is started, it opens a new workbook. The excel window then shows "Microsoft Excel - Book 1".
Is there a way to modify this at runtime? I would like this window header to convey an important message to the user (status info) ...

Thymen

Justinlabenne
03-12-2006, 10:31 AM
Anytime Excel starts, or a new workbook started from an application you have?

Thymen
03-12-2006, 12:15 PM
Actually I want to be able to change then name of the window at will. Meaning I can use it to convey a status message.

I use an Excel (with lots of VBA code ) code as a base workbook, but the data generated is exported to another file, and loaded back when needed. I would like to state the name of the data file in the Excel base window.

Thymen

Norie
03-12-2006, 01:26 PM
Thymen

You might want to look at the Caption property of the Application object.


Application.Caption = "MyCaption"

Thymen
03-12-2006, 04:41 PM
Application.caption, I knew it would be simple..... Thanks!

However, It modifies only the "Microsoft Excel"-part. And even though that is already more then nothing, is there a way to overrule the workbook name too? Without compromising anything ofcourse..

Thymen

Desert Piranha
03-12-2006, 04:55 PM
Application.caption, I knew it would be simple..... Thanks!

However, It modifies only the "Microsoft Excel"-part. And even though that is already more then nothing, is there a way to overrule the workbook name too? Without compromising anything ofcourse..

Thymen
Hi Thymen,

Try

'ActiveWindow.Caption = "Your Caption" 'changes entire caption

'ActiveWindow.Caption = False 'Restores Default

'ActiveWindow.Caption = "" 'shows nothing

smc2911
03-12-2006, 05:33 PM
Interesting inconsistency: Application and ActiveWindow have different mechanisms for resetting to default behaviour:

Application.Caption = ""
ActiveWindow.Caption = False

If you use False for Application, you get the literal word "False".

Sean.

Desert Piranha
03-12-2006, 05:41 PM
Sorry, ignor this.

Thymen
03-13-2006, 02:33 PM
Private Sub CommandButton1_Click()
Application.Caption = "First text" ' dash -
ActiveWindow.Caption = "Second Text"
End Sub

That does it........ Can't get rid of the dash, though...

Thymen

Desert Piranha
03-13-2006, 02:43 PM
Private Sub CommandButton1_Click()
Application.Caption = "First text" ' dash -
ActiveWindow.Caption = "Second Text"
End Sub

That does it........ Can't get rid of the dash, though...

Thymen Hi Thymen,

Glad it is working for you.

I don't understand what you mean by:
"Can't get rid of the dash, though..."

There is no dash when i try it.

Thymen
03-13-2006, 02:51 PM
Piranha,
with me the window caption is "First Text - Second Text", with a dash between the two.

OS = WXP, Office = 2000

Thymen

Desert Piranha
03-13-2006, 06:14 PM
Piranha,
with me the window caption is "First Text - Second Text", with a dash between the two.

OS = WXP, Office = 2000

ThymenHi Thymen,
Very interisting, the code as posted gives me, "First text" on the main Excel window, and "Second Text" on the workbook window.I tried it on Xp Home, XP Pro, with Office2000.


Private Sub CommandButton1_Click()
Application.Caption = "First text" ' dash -
ActiveWindow.Caption = "Second Text"
End Sub

smc2911
03-14-2006, 02:48 AM
This one is easily explained. As is evident from the commands, the caption for the Application (Excel itself) is "First Text", while the caption for the workbook is "Second Text". When the workbook is not maximised in the Excel window, the result is as displayed by Desert Piranha. If the workbook is maximised, the result is "First Text - Second Text" on Excel's title bar as the workbook's title bar has disappeared (see image). So, I assume that Thymen is working with a maximised workbook. The workaround then is simply to set the workbook caption to be blank, using ActiveWorkbook.Caption = "". There will then be no dash.

Sean.

Desert Piranha
03-14-2006, 08:56 AM
When the workbook is not maximised in the Excel window, the result is as displayed by Desert Piranha. If the workbook is maximised, the result is "First Text - Second Text" on Excel's title bar as the workbook's title bar has disappeared.
Sean.Hi smc,
Thanks for teaching me something new here. Soooo simple when you know what you are doing.

smc2911
03-15-2006, 03:13 AM
I so rarely know what I'm doing, so I do enjoy the odd occasion when I do!

malik641
03-15-2006, 08:51 AM
This is some good info :thumb Love learning new stuff :yes