vbsscript runtime error : object required

已答覆 vbsscript runtime error : object required

  • Friday, December 07, 2012 10:48 AM
     
      Has Code

    Hi

    I am very new to vbs script and hope for you help in order to get the below code working.

    I get the following error:

    1. Line: 3
    2. Char: 1
    3. Error: Object required: Description
    4. Code: 800A01A8
    5. Source: Microsoft VBScript runtime error

    The code I am trying:

    Dim oDesc
    
    Set oDesc = Description.Create
    oDesc( "micclass" ).Value = "Browser"
     
    'Close all browsers except Quality Center
    
    If Desktop.ChildObjects(oDesc).Count > 0 Then
        For x = Desktop.ChildObjects(oDesc).Count - 1 To 0 Step -1
           If InStr(1, Browser("creationtime:="&x).GetROProperty("name"), "Quality Center") = 0 Then  
              Browser( "creationtime:=" & x ).Close
           End If
        Next
    End If

    Thank you in advance for helping a rookie:)

    BR Rasmus

All Replies

  • Friday, December 07, 2012 11:33 AM
     
     
    What are you actually trying to do?
  • Friday, December 07, 2012 11:39 AM
     
     

    I am trying to tell IE to close all tabs besides the one called quality center.

  • Friday, December 07, 2012 11:52 AM
     
      Has Code

    I am trying to tell IE to close all tabs besides the one called quality center.

    For a beginner you are trying your hand at something that is very ambitious. Your very first line of code does not work:

    Set oDesc = Description.Create

    What you need is to create an object for Internet Explorer, e.g. like so:
    Set oIE = CreateObject("InternetExplorer.Application")

    For methods to manipulate tabs, have a look at Tom Laveda's reply in this thread that deals with a similar question.

  • Friday, December 07, 2012 12:41 PM
     
     

    thanks for the link but as you say I am just a beginner.

    is it possible for you to adjust my code so it works?

    thanks.

  • Friday, December 07, 2012 1:08 PM
     
     Answered

    thanks for the link but as you say I am just a beginner.

    is it possible for you to adjust my code so it works?

    thanks.

    To make your code work I would have to completely rewrite it. Unfortunately for you this forum is not a free code-delivery service. You will get plenty of help here but you have to write most of the code yourself. If I was in your position then I would study Tom's code in detail, play with it, modify it until I had a good understanding of every code line. You could also post snippets here and I'm sure that Tom would love to explain what it does.

    And as I suggested before: If you are a beginner in VB Scripting then you should start with simple things. Download the help file script56.chm from the Microsoft site. It explains all the basic functions and it has lots of examples.