There is no Wait Method associated with Application in VisualBasic Word

后端 未结 3 770
执笔经年
执笔经年 2020-12-22 02:55

I have VBA code to run a particular code and I am trying to pause the next execution by giving it a wait time of 3 seconds using the following line:

Applicat         


        
3条回答
  •  旧时难觅i
    2020-12-22 03:41

    This works for me:

    Set wsh = VBA.CreateObject("WScript.Shell")
       Dim waitOnReturn As Boolean: waitOnReturn = True
       Dim windowStyle As Integer: windowStyle = 0
       Dim errorCode As Integer
    
       errorCode = wsh.Run("timeout 5", windowStyle, waitOnReturn)
    

    this code allows to run cmd command and wait until execution is finished, in this particular case I am running command "timeout 5" which simly wait 5 seconds. I've found documentation here

提交回复
热议问题