[RESOLVED] Excel gets locked when executing a macro
Hi Guys,
I am running a macro to extract data from a mainframe terminal emulator through a VBA macro in excel.
The macro works fine and gives me the desired output. But after I execute the script, if I navigate to see the mainframe terminal am not able to view the excel sheet until the macro gets completed.
Is there a any specific option that i can use to keep the excel sheet viewable when the macro is in execution?
Please help!
Re: Excel gets locked when executing a macro
Thread moved from the 'Database Development' forum to the 'Office Development/VBA' forum
Re: Excel gets locked when executing a macro
In most cases I'd try the other way around (i.e. not update the worksheet while the macro is running).
Did you use the "application.screenupdating=False"?
Re: Excel gets locked when executing a macro
Quote:
Is there a any specific option that i can use to keep the excel sheet viewable when the macro is in execution?
you can use doevents to help with this (yields to other processes), with in any loop
avoid using selection, select, activate or active anything within your code, as these all slow down the processing and increase possibility of errors ocurring
Re: Excel gets locked when executing a macro
Re: Excel gets locked when executing a macro
@opus - I am not using "application.screenupdating=False"!
@westconn1 - could you please brief me more on the "doevents"?
@kaliman79912 - here is the sample code that am using:
"Private app As PASSOBJLib.System
Private session As PASSOBJLib.session
Private screen As PASSOBJLib.screen
Private Wkbook As excel.Workbook
Private Wksht As excel.Worksheet
Dim Var As String
Sub Mainframe_Connect()
Set app = New PASSOBJLib.System
Set session = app.ActiveSession
Set screen = session.screen
For i = 1 To 20
screen.SendKeys ("<Home>")
screen.SendKeys ("3.4")
screen.SendKeys ("<Enter>")
screen.SendKeys ("<PF3>")
Next
End Sub"
Re: Excel gets locked when executing a macro
vb Code:
For i = 1 To 20
screen.SendKeys ("<Home>")
screen.SendKeys ("3.4")
screen.SendKeys ("<Enter>")
screen.SendKeys ("<PF3>")
doevents
Next
i doubt that preventing screenupdating will help you or be desirable in this case
Re: Excel gets locked when executing a macro
@westconn1 - Thanks a ton! Works cool...lil slow though which is understandable...
Thanks again!
Re: [RESOLVED] Excel gets locked when executing a macro
what do you have in <PF3>? You might be able to do what you want without sending keys, which has very bad performance.
Re: [RESOLVED] Excel gets locked when executing a macro
<PF3> is a keystroke action which i need to perform in the mainframe screen.
(ie.,) i need to press the F3 key which is defined as PF3 in the mainframe emulator..
Thoughts?