+ Reply to Thread
Results 1 to 7 of 7

Help to enhance/improve this vb script

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-17-2011
    Location
    PH
    MS-Off Ver
    Excel 2007
    Posts
    183

    Help to enhance/improve this vb script

    Hi Expert,

    I have a vb script that call/open an SSRS link from IE9. Right now my script displayed/open only 1 page.
    May I ask your help to enhance this script.

    1. I wanted when the first page (1) Open then after 5 mins. the frist page(1) will be close then the second page will be show/open.
    basically for both pages the interval time to open/run is 5 mins.

    2. I possible to fit into the screen the display using script.

    The main objective is automate display the result of SSRS in an LCD monitor that can be viewed by workers.
    The can see the data real time and they have to make a decision if there's an immidiate needs to work for the production output.

    Or Do you have any idea? THank you in advance.

    Dim ie, objshl, wnd, shl
    
    Set shl = CreateObject("Shell.Application")
    On Error Resume Next
    For Each wnd In shl.Windows
        If InStr(1, wnd.Fullname, "iexplore.exe", vbTextCompare) > 0 Then
            Set ie = wnd
            ie.Quit
         End If
    Next
    DoEvents
    
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Navigate "https://www.yahoo.com/"  -- This is on a sample page..Origal page will be an SSRS report link.
    Do While ie.Busy
    
    Loop
    ie.Visible = True
    ie.FullScreen = True
    
    
    CreateObject("WScript.Shell").AppActivate ie.Name
    Set ie = Nothing

  2. #2
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Help to enhance/improve this vb script

    Hi,

    You can add the following code to open second page after specified time :

    Application.Wait (Now + TimeValue("00:00:10"))
    This is sample code, you need to change it as per your requirement.
    And to change the URL of the SSRS link, keep it in the Do while Loop

    Like this :

    Do While ..
    
    navigate to https://www.SSRS.com/page=i
    
    then go for wait
    
    Application.Wait (Now + TimeValue("00:00:10"))
    
    Loop
    where you need to increment the value of i and then apply .wait function



    Regards,
    Paresh J
    Click on "* Add Reputation" as a way to say thanks

  3. #3
    Forum Contributor
    Join Date
    07-17-2011
    Location
    PH
    MS-Off Ver
    Excel 2007
    Posts
    183

    Re: Help to enhance/improve this vb script

    Hi Paresh J,

    I tried to insert the google.com based on the codes you have given but its not working.

    i wanted to run first the yahoo then let say 5 minutes then after 5 minutes i wanted to run the google.. vice versa...

  4. #4
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Help to enhance/improve this vb script

    Hi,

    If only two sites you want to check after 5 mins then what you can is, check the following code:

    i=1
    Do While ..
    If i =1 then 
    navigate to yahoo and then wait for the specific time you want to
    Application.Wait (Now + TimeValue("00:00:10"))  '' change this as per your requirement
    i = i + 1
    ElseIf i = 2 then
    navigate to google and then wait for the specific time you want to
    Application.Wait (Now + TimeValue("00:00:10"))  '' change this as per your requirement
    i = 1
    EndIf
    Loop
    Regards,
    Paresh J

  5. #5
    Forum Contributor
    Join Date
    07-17-2011
    Location
    PH
    MS-Off Ver
    Excel 2007
    Posts
    183

    Re: Help to enhance/improve this vb script

    Hi Paresh J,

    Try to run the codes you have given, I encounter an error. Please see modified scripts. maybe i have a missing codes.

    Dim ie, objshl, wnd, shl
    
    Set shl = CreateObject("Shell.Application")
    On Error Resume Next
    For Each wnd In shl.Windows
        If InStr(1, wnd.Fullname, "iexplore.exe", vbTextCompare) > 0 Then
            Set ie = wnd
            ie.Quit
         End If
    Next
    DoEvents
    
    Set ie = CreateObject("InternetExplorer.Application")
    
    i=1
    Do While ie.busy
      If i =1 then 
         ie.Navigate "https://login.yahoo.com/?.src=ym&.intl=us&.lang=en-US&.done=http://mail.yahoo.com"  
         Application.Wait (Now + TimeValue("00:05:00"))  '' change this as per your requirement
         i = i + 1
      ElseIf i = 2 then
         ie.Navigate "https://www.google.com.ph/?gws_rd=ssl"
         Application.Wait (Now + TimeValue("00:05:00"))  '' change this as per your requirement
         i = 1
      EndIf
    Loop
    
    ie.Visible = True
    ie.FullScreen = True
    
    CreateObject("WScript.Shell").AppActivate ie.Name
    Set ie = Nothing

  6. #6
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Help to enhance/improve this vb script

    Hi,

    Try this code:


    Sub try()
    
    Dim ie, objshl, wnd, shl
    
    Set shl = CreateObject("Shell.Application")
    On Error Resume Next
    For Each wnd In shl.Windows
        If InStr(1, wnd.FullName, "iexplore.exe", vbTextCompare) > 0 Then
            Set ie = wnd
            ie.Quit
         End If
    Next
    DoEvents
    
    Set ie = CreateObject("InternetExplorer.Application")
    
    i = 1
    ie.Visible = True
    'ie.FullScreen = True
    
    Do While Not ie.busy
      If i = 1 Then
         ie.Navigate "https://login.yahoo.com/?.src=ym&.intl=us&.lang=en-US&.done=http://mail.yahoo.com"
         Application.Wait (Now + TimeValue("00:05:00"))  '' change this as per your requirement
         i = i + 1
      ElseIf i = 2 Then
         ie.Navigate "https://www.google.com.ph/?gws_rd=ssl"
         Application.Wait (Now + TimeValue("00:05:00"))  '' change this as per your requirement
         i = 1
      End If
    Loop
    
    
    
    CreateObject("WScript.Shell").AppActivate ie.Name
    Set ie = Nothing
    
    End Sub

    Note : If you dont want to continue do while loop for long to can break and come out of it.
    Like below:

    If i = 2 Then
       Exit Do
    End If
    Put this code inside do while in elseif part.


    Regards,
    Paresh J
    Last edited by pareshj; 06-22-2014 at 11:14 PM.

  7. #7
    Forum Contributor
    Join Date
    07-17-2011
    Location
    PH
    MS-Off Ver
    Excel 2007
    Posts
    183

    Re: Help to enhance/improve this vb script

    Hi Paresh J, thank you very much for your prompt reply.

    Compile the code to .vbs script and run through task manager to repeatedly run the codes for every 15 minutes (for testing).
    Basically it should run the codes 5 minutes for yahoo and then after 5 minutes the google will come up. therefor, upon testing the first URL come up is yahoo, i'm waiting for almost 6 mis. the google did not come up. Then try to put a msgbox after the application wait, then clicking the message box the google come out.

    btw, is possible to run simultaneously both the URL then automate the tab that should be open. just another idea if its doable. thank you.

+ 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. Need help to enhance and improve VBA code. Need to end the operations
    By BrandonFromSingapore in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2012, 03:34 AM
  2. enhance IF formula
    By m1066189 in forum Excel General
    Replies: 4
    Last Post: 06-10-2010, 01:16 PM
  3. Enhance wordlist through synonyms in Col.D
    By wali in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-25-2008, 11:56 PM
  4. Enhance VB Project Security
    By ern2ern in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-25-2007, 12:38 PM
  5. [SOLVED] what do you use to enhance financial data?
    By nicole in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-11-2005, 06:06 PM

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