View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default activating windows

Matthew Dyer was thinking very hard :
On Mar 10, 2:37*pm, GS wrote:
GS used his keyboard to write :

If Not sName = "" Then Workbooks(sName).Activate


change to...

* If Not sName = "" Then Application.Windows(sName).Activate

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


sorry garry, but it isnt working.

For Each wnd In Application.Windows
If InStr(1, wnd.Caption, TextIn, vbTextCompare) 0 Then _
GetWkbNameFromWindow = wnd.Caption: Exit Function
Next

wnd comes back as Nothing and remains nothing throughout when the code
is run. I ran it with breaks. It also appears to be running only for
the 'active' window and not trying to pull data from any of the other
windows to find the match.


Are you using the function 'as posted'? It will only work if there's at
least 1 workbook open. If more then it steps through each window to
check if the string you passed is contained in its Caption. What are
you doing different that's making it NOT work?

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc