Closed Thread
Results 1 to 3 of 3

how to access worksheet and namerange

Hybrid View

  1. #1
    Registered User
    Join Date
    02-16-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    78

    how to access worksheet and namerange

    Hi,

    I have a function to read an XML document (stored in physical file system)and Put values in a another worksheet in a workbook.
    I am able to open the workbook , but i need to access the worksheet (itz name is "PutDataSheet")

    I have also created name range for the cells in the 'PutDataSheet" and need to refer them with the name while putting values.

    I try to access the Worksheet as Source.WorkSheets("PutDataSheet") but throwz an error..

    can u please tell how to access
    the worksheet and also the namerange inside the worksheet to assign values.
    Anywayz i am accessing the namerange as


    Sheet.Range("PutDataSheet.Name") = node.SelectSingleNode("Name").Text

    Below is the function for ur reference..

    Function ReadXMLDocument(SheetName As String)

    Dim xml_Doc As DOMDocument
    Dim list As IXMLDOMNodeList
    Dim node As IXMLDOMNode
    Dim Sheet As Worksheet
    Dim xlApp As Excel.Application
    Dim Source As Workbook

    Const MyDir As String = "c:\temp\"
    Set xmlDoc = New DOMDocument
    xmlDoc.Load "C:\temp\WellConfig.xml"

    Set xlApp = New Excel.Application
    Set Source = xlApp.Workbooks.Open(MyDir & "Summary.xls")
    ' Sheet = Source.Worksheets("PutDataSheet")


    Set booklist = xmlDoc.DocumentElement.SelectNodes("WellConfig")
    For Each node In list
    Sheet.Range("PutDataSheet.Name") = node.SelectSingleNode("Name").Text
    Sheet.Range("PutDataSheet.Operator") = node.SelectSingleNode("OperatingCompany").Text

    Next

    End Function

    Thanks
    Ranjani

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: how to access worksheet and namerange

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: how to access worksheet and namerange

    Thread closed.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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