+ Reply to Thread
Results 1 to 3 of 3

Does the object already have a value set?

  1. #1
    Hari
    Guest

    Does the object already have a value set?

    Hi,

    I have an workbook object named "RespWkbook"

    I would like to check whether I have already assigned a workbook to it.
    If so then I would like to close the assign that workbook (because it
    has become old for me) and set a new workbook to RespWkBook.

    I tried

    if Not(IsNull(RespWkbook)) then RespWkbook.close
    set RspWbook = "//hari/desktop/NewWrkBook.xls"

    But it didnt work

    I also tried

    if Not(Isempty(RespWkbook)) then RespWkbook.close
    set Respwkbook = "//hari/desktop/NewworkBook.xls"

    again it is not working.

    Whats the right syntax for checking whether an object has value Nothing
    or not and be able to do the operation I want to do?

    Rgards,
    Hari
    India


  2. #2
    Chip Pearson
    Guest

    Re: Does the object already have a value set?

    Try

    If RespWkbook Is Nothing Then
    ' no workbook assigned
    Else
    ' workbook assigned
    End If


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com





    "Hari" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have an workbook object named "RespWkbook"
    >
    > I would like to check whether I have already assigned a
    > workbook to it.
    > If so then I would like to close the assign that workbook
    > (because it
    > has become old for me) and set a new workbook to RespWkBook.
    >
    > I tried
    >
    > if Not(IsNull(RespWkbook)) then RespWkbook.close
    > set RspWbook = "//hari/desktop/NewWrkBook.xls"
    >
    > But it didnt work
    >
    > I also tried
    >
    > if Not(Isempty(RespWkbook)) then RespWkbook.close
    > set Respwkbook = "//hari/desktop/NewworkBook.xls"
    >
    > again it is not working.
    >
    > Whats the right syntax for checking whether an object has value
    > Nothing
    > or not and be able to do the operation I want to do?
    >
    > Rgards,
    > Hari
    > India
    >




  3. #3
    Hari
    Guest

    Re: Does the object already have a value set?

    Chip,

    Thanx a lot. It works nicely.

    Regards,
    Hari
    India


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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