Results 1 to 2 of 2
  1. #1
    ry94080 is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    36

    CreateObject set focus away

    Hello,



    I have an Access application that opens another application via CreateObject and runs through some scripts. Works fine. However, sometimes when multitasking with Word for example and typing. The CreateObject pops up WITH FOCUS and while i'm typing in Word will start to capture my strokes messing up my script.

    Question. Is there a way to set focus away when it opens or open it in such away it does not accept any user input while running it's script?

    Below is the example code i have for opening up the application.

    Code:
    Sub PullPendingLog_SmarTermOn Error GoTo PullPendingLog_SmarTerm_Err
    Set Application = CreateObject("SmarTerm.Application")
    Set Session = Application.Sessions.Open("\\dcms1ms\sharedlabs\Laboratory\LAB USE ONLY\Web Shortcuts\SmarTerm\SmarTerm SQLAB Live LVR.stw")
    
    
    
    
    sDir = "C:\Documents and Settings\" & UserNameWindows & "\Application Data\MST Pending"
    sTextFileName = "URC_Pending.txt"
    
    
    'With Application
        Application.Visible = True

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    I presume you mean user input in access.

    You don't show what other code you have within your with and beyond but you could try


    Code:
    with application
        .visible=true
        do
            doevents
        while .visible=true
    end with
    I use this for forms which I want to act like a dialog form, but need to pass back values before the form closes. Since this is a separate application, you may need to use something else instead of .visible =true. Depends how you close the application, perhaps trapping an error (e.g. while .err=0)

    if you are talking about setting the focus to the application - you will need to check the application or session properties for a setfocus type of property

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Force focus away from a tab page on the hour
    By dcdimon in forum Programming
    Replies: 3
    Last Post: 07-22-2014, 07:09 AM
  2. Replies: 1
    Last Post: 09-20-2012, 03:37 PM
  3. Replies: 0
    Last Post: 02-22-2011, 04:18 PM
  4. If Then CreateObject
    By cg1465 in forum Forms
    Replies: 3
    Last Post: 09-28-2010, 07:06 PM
  5. How do I specify a version of Word using CreateObject?
    By TrevorOlding in forum Programming
    Replies: 1
    Last Post: 03-17-2006, 12:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums