View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Clif McIrvin[_3_] Clif McIrvin[_3_] is offline
external usenet poster
 
Posts: 203
Default activating windows

"GS" wrote in message
...
Matthew Dyer laid this down on his screen :
On Mar 10, 3:14 pm, GS wrote:
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 athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc- Hide quoted
text -

- Show quoted text -


copy/paste of the function with no modifications. I think Clif may
be
on to something about it being a different instance of excel...
reccomendations?


The ref to 'Application' in the function is the current instance of
Excel in which the code is running. The function won't work on other
instances running at the same time. Not sure why this would be an
issue since most users use the same instance of Excel for all open
workbooks. In order for me to have multiple instances open at the same
time it would be a deliberate action on my part to do so. (Not
withstanding automated instances)



It's easy enough to discover if there are multiple instances running by
using Task Manager. On XP, my normal way to launch Task Manager is
Ctrl+Alt+Del which brings up a dialog and one of the choices is Task
Manager.

When Task Manager opens, select the Processes (NOT Applications) tab and
look for multiple entries for EXCEL.EXE.

If there's only one, there is only one instance running on that
computer.

--
Clif McIrvin

(clare reads his mail with moe, nomail feeds the bit bucket :-)