Results 1 to 10 of 10

Thread: [RESOLVED] Excel gets locked when executing a macro

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    9

    Resolved [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!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Excel gets locked when executing a macro

    Thread moved from the 'Database Development' forum to the 'Office Development/VBA' forum

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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!

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  5. #5
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Excel gets locked when executing a macro

    show your 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

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    9

    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"

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Excel gets locked when executing a macro

    vb Code:
    1. For i = 1 To 20
    2.  
    3. screen.SendKeys ("<Home>")
    4. screen.SendKeys ("3.4")
    5. screen.SendKeys ("<Enter>")
    6. screen.SendKeys ("<PF3>")
    7. doevents
    8. 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

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    9

    Re: Excel gets locked when executing a macro

    @westconn1 - Thanks a ton! Works cool...lil slow though which is understandable...

    Thanks again!

  9. #9
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    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

  10. #10

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    9

    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
  •  



Click Here to Expand Forum to Full Width