+ Reply to Thread
Results 1 to 5 of 5

VBA query to SAP

  1. #1
    Registered User
    Join Date
    03-29-2017
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    60

    VBA query to SAP

    I'm using VBA to connect to SAP to collect information. The T/C I'm calling though takes a little bit of time to open. Can someone please point me in the right direction to have my macro wait until the transaction is finished loading before continuing? Below is the snippet of my code so far.
    HTML Code: 

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: VBA query to SAP

    Hi billyjo,

    You need to add "DoEvents" between your lines giving the OS time to complete.

    https://msdn.microsoft.com/en-us/lib.../gg264522.aspx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-29-2017
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    60

    Re: VBA query to SAP

    I'm not sure I understand the context of how to use that function Marvin, can you give me an example such as how I would apply it to the end of my snippet I posted above?

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: VBA query to SAP

    Hi,

    In VBA you can do things that the Operating System does, like save a file or open something. If you don't tell VBA to wait until the OS is done, your VBA will fire stuff before the OS is ready to receive the information.

    In VBA if you have:

    File.Open
    File.Open

    If is safer to do a:

    File.Open
    DoEvents
    File.Open

    The "DoEvents" tells VBA to wait until the OS is done before trying to do the next step. The idea is that with Windows, all those programs that are in memory need service. Windows goes around asking if they need CPU time. DoEvents waits for the CPU to get back to your VBA code before sending the next command.

  5. #5
    Registered User
    Join Date
    03-29-2017
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    60

    Re: VBA query to SAP

    Worked like a charm. Thanks Marvin!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 01-24-2017, 11:22 AM
  2. Replies: 0
    Last Post: 03-22-2016, 05:14 PM
  3. Replies: 1
    Last Post: 09-08-2015, 08:12 PM
  4. Replies: 2
    Last Post: 02-01-2013, 04:21 PM
  5. [SOLVED] Loop through list, perform web query and save each query on its own page
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2012, 07:50 AM
  6. Problem with selecting range with in query table after query refresh
    By shooter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-31-2012, 11:55 AM
  7. Web Query - Change a word in query to form a new query
    By scottymelloty in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2011, 04:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1