+ Reply to Thread
Results 1 to 14 of 14

Object Variable or with block variable not set.

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Object Variable or with block variable not set.

    I have an error that I just can't figure.

    Please Login or Register  to view this content.
    Last edited by AnthonyWB; 06-22-2011 at 12:32 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Object Variable or with block variable not set.

    This error is occuring because you are trying to set a workbook type variable to a string value. Try this instead:

    Please Login or Register  to view this content.
    Instead of
    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Object Variable or with block variable not set.

    I am now getting a subscript out of range:

    Please Login or Register  to view this content.
    Any ideas?

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Object Variable or with block variable not set.

    Sounds like the file is not there. Make sure you have all your slashes.

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Object Variable or with block variable not set.

    well the file name should read as an example:

    Option EPMS Valuation 3-31-11.xlsx

    Perhaps I need to account for the spaces?

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Object Variable or with block variable not set.

    Look at what you have put together in your code. Right now it is:

    XXX:\Users\YYYYY1\Desktop\Option EPMS Valuation 03-31-11.xls.

    You need to change the month to a single character to get rid of the zero in front of the 3.

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Object Variable or with block variable not set.

    Thanks, but still not working. Take a look at what I have done:


    Please Login or Register  to view this content.
    and then,

    Please Login or Register  to view this content.

    I am still geting a subscript out of range.

  8. #8
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Object Variable or with block variable not set.

    Use the immediate window to check the file path and name and compare it to the filepath and name in the windows explorer.

  9. #9
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Object Variable or with block variable not set.

    Dave thanks for following me on this one.

    Acording to the Immediate window:

    Please Login or Register  to view this content.

    yields the error: Object Variable or with Block Variable not set. All the other variables pan out exactly the way they should.

  10. #10
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Object Variable or with block variable not set.

    Do this:

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Object Variable or with block variable not set.

    Yep its what I thought, there is no space after Valuation and date.

    Please Login or Register  to view this content.
    we just need to add a space. I have tried the following and it does not correct the issue:

    Please Login or Register  to view this content.
    Note the space in the date format.

  12. #12
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Object Variable or with block variable not set.

    Like this instead:

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Object Variable or with block variable not set.

    Almost there.

    Please Login or Register  to view this content.

    is correct. But WrkbookPrior = Nothing. The file does exist and its on my desktop. According to the properties of the file the name of the file is: Option EPMS Valuation 12-31-10.xlsx and it is in the folder C:\Users\AHernandez1\Desktop

  14. #14
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Object Variable or with block variable not set.

    Please Login or Register  to view this content.
    Not sure why I wrote this wrong earlier.

+ 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