Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
act win failing with multiple excel documents
#1
Here's the code:
act win("test.xls")

This works fine the first time, and if test.xls was the last workbook I viewed in Excel.
However if I:
- run this command
- activates test.xls ok
- switch to another workbook in Excel (with Ctrl-F6 or Alt-tab)
- run the command again
- activates test.xls ok
- then after about 5 seconds gives the error: Error (RT) in "<macro>": cannot activate window

I am using Office 2007 SP1 on Windows XP SP2.
QM 2.2.? and 2.3.0.1 have the same behaviour/problem.
This behaviour does not occur with Word documents, ie act win("test.doc") always works without error.
#2
I looked a little closer:
out
ARRAY(int) a; int i; str sc sn
out "[][9]ALL VISIBLE WINDOWS"
win("" "" "" 0 0 0 a)
for(i 0 a.len)
sc.getwinclass(a[i])
sn.getwintext(a[i])
out "%i '%s' '%s'" a[i] sc sn
if (matchw(sn "hours.xls*"))
out _s.from("YES: " a[i])
act a[i]
err
out _s.from(" error: " win " " sn.getwintext(win))

Generates:

ALL VISIBLE WINDOWS
131332 'Shell_TrayWnd' ''
66280 'QM_toolbar' 'QM TOOLBAR'
65894 'QM_Editor' 'Quick Macros - Main - [ListWindows]'
1771744 'XLMAIN' 'Microsoft Excel - hours.xls [Compatibility Mode]'
1443532 'MS-SDIb' 'hours.xls [Compatibility Mode]'
YES: 1443532
error: 1771744 Microsoft Excel - hours.xls [Compatibility Mode]
1508358 'HH Parent' 'QM Help'
330866 'MS-SDIb' 'test.xls [Compatibility Mode]'
2360296 'MozillaUIWindowClass' 'Quick Macros Forum • View forum - Programming - Mozilla Firefox'
396396 'MS-SDIb' 'Tasks Core.xls [Compatibility Mode]'
1312986 'rctrl_renwnd32' 'Inbox - Microsoft Outlook'
721034 'CabinetWClass' '\\s01'
2754560 'CabinetWClass' 'D:\'
1247808 'ExploreWClass' 'My Computer'
1837250 'ConsoleWindowClass' 'C:\WINDOWS\system32\cmd.exe'
264490 'ConsoleWindowClass' 'C:\WINDOWS\system32\cmd.exe'
527272 'TSSHELLWND' 'administrator-corepn - s34.corepn.local - Remote Desktop'
201188 'TSSHELLWND' 'administrator-corepn - s33.corepn.local - Remote Desktop'
790094 'IrfanView' 'Clipboard01 - IrfanView'
852788 'rctrl_renwnd32' 'RE: New versions of Boris and Aviarc - Message (HTML) '
131378 'Progman' 'Program Manager'

It looks like Excel activates its main window, causing QM to think the window did not activate.
Any suggestions for how I should code this to work without QM errors?
#3
act "test.xls"
err

or

AllowActivateWindows
SetForegroundWindow win("test.xls")

or

Macro
Code:
Copy      Help
act "Excel"
ExcelSheet es.Init("" 2 "test.xls")


Forum Jump:


Users browsing this thread: 1 Guest(s)