|
-
Nov 21st, 2011, 08:30 AM
#1
Thread Starter
New Member
[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!
-
Nov 21st, 2011, 08:51 AM
#2
Re: Excel gets locked when executing a macro
Thread moved from the 'Database Development' forum to the 'Office Development/VBA' forum
-
Nov 21st, 2011, 09:02 AM
#3
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"?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Nov 21st, 2011, 03:29 PM
#4
Re: Excel gets locked when executing a macro
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 21st, 2011, 04:44 PM
#5
Re: Excel gets locked when executing a macro
More important than the will to succeed, is the will to prepare for success.
Please rate the posts, your comments are the fuel to keep helping people
-
Nov 23rd, 2011, 04:41 AM
#6
Thread Starter
New Member
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"
-
Nov 23rd, 2011, 05:14 AM
#7
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 23rd, 2011, 05:23 AM
#8
Thread Starter
New Member
Re: Excel gets locked when executing a macro
@westconn1 - Thanks a ton! Works cool...lil slow though which is understandable...
Thanks again!
-
Nov 23rd, 2011, 05:29 PM
#9
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.
More important than the will to succeed, is the will to prepare for success.
Please rate the posts, your comments are the fuel to keep helping people
-
Nov 24th, 2011, 12:17 AM
#10
Thread Starter
New Member
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|