Skip to Content
avatar image
-1
Former Member

At end of script new Print dialog box open. I want to automate please suggest code

The above dialog box open

I want to automate through Excel VBA Script

Please suggest code.

sap.jpg (35.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Aug 30, 2017 at 07:30 AM

    Hi Pavan,

    I did use this workaround for years.

    Regards,

    ScriptMan

    set Wshell = CreateObject("WScript.Shell")
    Do 
     bWindowFound = Wshell.AppActivate("Print")
     WScript.Sleep 1000
    Loop Until bWindowFound
    bWindowFound = Wshell.AppActivate("Print")
    if (bWindowFound) Then
      Wshell.appActivate "Print"
      WScript.Sleep 100
      Wshell.sendkeys "{ENTER}"
    end if
    bWindowFound = Wshell.AppActivate("Print")
    if (bWindowFound) Then
      Wshell.appActivate "Print"
      WScript.Sleep 100
      Wshell.sendkeys "{TAB}{ENTER}"
    end if
    bWindowFound = Wshell.AppActivate("Print")
    if (bWindowFound) Then
      Wshell.appActivate "Print"
      WScript.Sleep 100
      Wshell.sendkeys "{TAB}{TAB}{ENTER}"
    end if
    on error resume next
    session.findById("wnd[1]").close
    on error goto 0
    
    Add comment
    10|10000 characters needed characters exceeded

  • Sep 07, 2017 at 01:26 PM

    Hi Pavan,

    the above solution was only for VBS. The solution below can also be used for VBA.

    Regards,

    ScriptMan

    Set wshell = CreateObject("WScript.Shell")
    Do
     bWindowFound = wshell.AppActivate("Print")
     'WScript.Sleep 1000
     wshell.Run "c:\tmp\sleep.vbs" & " 1000", 0, True
    Loop Until bWindowFound
    bWindowFound = wshell.AppActivate("Print")
    If (bWindowFound) Then
      wshell.AppActivate "Print"
      'WScript.Sleep 100
      wshell.Run "c:\tmp\sleep.vbs" & " 100", 0, True
      wshell.SendKeys "{ENTER}"
    End If
    bWindowFound = wshell.AppActivate("Print")
    If (bWindowFound) Then
      wshell.AppActivate "Print"
      'WScript.Sleep 100
      wshell.Run "c:\tmp\sleep.vbs" & " 100", 0, True
      wshell.SendKeys "{TAB}{ENTER}"
    End If
    bWindowFound = wshell.AppActivate("Print")
    If (bWindowFound) Then
      wshell.AppActivate "Print"
      'WScript.Sleep 100
      wshell.Run "c:\tmp\sleep.vbs" & " 100", 0, True
      wshell.SendKeys "{TAB}{TAB}{ENTER}"
    End If
    bWindowFound = wshell.AppActivate("Print")
    While (bWindowFound)
      'WScript.Sleep 500
      wshell.Run "c:\tmp\sleep.vbs" & " 500", 0, True
      bWindowFound = wshell.AppActivate("Print")
    Wend
    On Error Resume Next
    session.findById("wnd[1]").Close
    On Error GoTo 0
    
    . . . 
    
    
    sleep.vbs in c:\tmp:
    
    set args = wscript.arguments
    if args.count>0 then
       Wscript.Sleep WScript.Arguments(0)
    else
     Wscript.Sleep 1000
    end if
    
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 16, 2017 at 03:19 PM

    Thank you

    Very much

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 30 at 07:14 AM

    set Wshell = CreateObject("WScript.Shell")
    Do 
     bWindowFound = Wshell.AppActivate("Print")
     WScript.Sleep 1000
    Loop Until bWindowFound
    bWindowFound = Wshell.AppActivate("Print")
    if (bWindowFound) Then
      Wshell.appActivate "Print"
      WScript.Sleep 100
      Wshell.sendkeys "{ENTER}"
    end if
    bWindowFound = Wshell.AppActivate("Print")
    if (bWindowFound) Then
      Wshell.appActivate "Print"
      WScript.Sleep 100
      Wshell.sendkeys "{TAB}{ENTER}"
    end if
    bWindowFound = Wshell.AppActivate("Print")
    if (bWindowFound) Then
      Wshell.appActivate "Print"
      WScript.Sleep 100
      Wshell.sendkeys "{TAB}{TAB}{ENTER}"
    end if
    on error resume next
    session.findById("wnd[1]").close
    on error goto 0
    base on your script, i would like to change numbers of copie?

    Can you help me, ScriptMan?

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 15 at 11:28 AM

    I'm sorry, but I only accidentally saw the question today.

    But you have to find out beforehand about which hotkey the number of copies can be jumped to. When the window appears at the manual call and is in the foreground, press the ALT key. At this moment a letter is underscored and this must be taken. Unfortunately, I work with a German version and can not test it here.

    My suggestion:

     set Wshell = CreateObject("WScript.Shell")
    Do 
     bWindowFound = Wshell.AppActivate("Print")
     WScript.Sleep 1000
    LoopUntil bWindowFond
    bWindowFound = Wshell.AppActivate("Print")
    if(bWindowFound)Then
      Wshell.appActivate "Print"
      WScript.Sleep 100
      Wshell.sendkeys "%n" 'or u,m,b,e,r...
      WScript.Sleep 100
      Wshell.sendkeys "2"
      WScript.Sleep 100
      Wshell.sendkeys "{TAB}"
      WScript.Sleep 100
      Wshell.sendkeys "{ENTER}"
    end if
    . . .
    

    Regards,

    ScriptMan

    Add comment
    10|10000 characters needed characters exceeded