arun_roy
arun_roy

Reputation: 601

Worksheet opening errors

when i am trying to get create an sheet object,getting the error:

    Dim oFS   : Set oFS  = CreateObject("Scripting.FileSystemObject")
    Dim oXls  : Set oXls = CreateObject("Excel.Application")
    Dim oWb   : Set oWb  = oXls.Workbooks.Open(oFs.GetAbsolutePathName("Wing_To_Wing_Report.xlsx"))
    Dim aData ': aData    = oWb.Worksheets(1).Range("$A2:$C10")
    Dim dicP  : Set dicP = CreateObject("Scripting.Dictionary")
    Dim Range,ObSheet1,ObSheet2
    Dim TotalRows,LastCol


    ObSheet1=oWb.ActiveWorkbook.Worksheets("WingToWingMay25")
    ObSheet2=oWb.ActiveWorkbook.Worksheets("ParentChildLink")

Tried this also:

   ObSheet1=oWb.Worksheets("WingToWingMay25")
   ObSheet2=oWb.Worksheets("ParentChildLink")

Error Object doesn't support this property or method: "ActiveWorkbook"

Can you help me here? why so.

Upvotes: 2

Views: 292

Answers (2)

Larry
Larry

Reputation: 2794

  1. oWb itself is a workbook object You don't need the ActiveWorkbook part
  2. you miss the set keyword in set ObSheet1=oWb.Worksheets("WingToWingMay25")

Also, I saw from one of your printscreen, you are using Notepad++ to develop,

Instead of just running the script directly,

please use a debugger to test the script.

You can find the debugger here

Using the debugger, you can run the source code line by line,

and use the watch window to see the properties of each object at runtime.

Upvotes: 3

stamhaney
stamhaney

Reputation: 1314

Instead of ObSheet1=oWb.ActiveWorkbook.Worksheets("WingToWingMay25") , you should do this :

set ObSheet1=oWb.ActiveWorkbook.Worksheets("WingToWingMay25")

Upvotes: 0

Related Questions