Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Macro Problem

Status
Not open for further replies.

jfhewitt

Technical User
Jun 6, 2000
287
US
I want to switch between windows in a macro, but want to identify the window by file name rather than "windows(1).activate". The number assigned to the window varies, and I want the window switch to be specific. How can I do this? TIA
 
Hi jfhewitt,

You do it using the window caption, which is normally the same as the document name (without the .doc on the end).

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Tony:
Thanks...but it doesn't work. What would the line of code be to select a particular window?
 

I have a two documents open at the moment - one is called "A4 TIMETABLE.doc" and the title bar says "A4 TIMETABLE - Microsoft Word" - it is Windows(1) and Windows(1).Caption returns "A4 TIMETABLE".

If I am in the other document and I run this macro ..

Sub ActWindow()
Windows("A4 TIMETABLE").Activate
End SUb

The WIndow with document "A4 TIMETABLE" becomes the active (top) window.

What do you get?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
You beat me to it...I forgot the quotes. Works fine now...thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top