+ Reply to Thread
Results 1 to 13 of 13

Problem Storing Object

  1. #1
    Registered User
    Join Date
    10-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Office Pro 2010
    Posts
    6

    Problem Storing Object

    Hi,

    I'm trying to write a macro in VBA which is similar to something I previously did in VB6. I'm not convinced the problem is a difference between them however I would have expected this code to work. Can anybody advise me what I'm doing wrong? This is a stripped down version of what I've got but uses the same calls etc and produces the same "424 - Object Required" error when I try to write the collection away.

    Please Login or Register  to view this content.
    csession.setobj looks like this :

    Please Login or Register  to view this content.
    Payments look like this

    Please Login or Register  to view this content.
    Have I missed something glaring?

    Thanks in advance.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Problem Storing Object

    I am not seeing where the csession object is created and I do not understand the Exists instruction in the setObj routine
    If you like my contribution click the star icon!

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Problem Storing Object

    You've defined colPayCollection as a collection and then your setObj asked for an object. I'm not really sure if it's the issue as I'd need the full code to debug it but I'd guess:
    Sub setObj(key As String, var As Collection)
    or
    Sub setObj(key As String, var As variant)

    Edit: changed my mind, don't think that is the issue anymore.. it might be something to do with variable types if it asks for an object when you try and call setObj...

    Upload your full code please.
    Last edited by ragulduy; 10-09-2013 at 09:47 AM.

  4. #4
    Registered User
    Join Date
    10-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Office Pro 2010
    Posts
    6

    Re: Problem Storing Object

    csession is a class module I've reused from the VB project I did which I use to write off objects/variables etc so they are accessible by different modules etc and it has some functions such as date extraction from string included.

    Here's the full csession class module :

    Please Login or Register  to view this content.

  5. #5
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Problem Storing Object

    at which exact statement are you getting the error message and is the csession object declared somewhere?

  6. #6
    Registered User
    Join Date
    10-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Office Pro 2010
    Posts
    6

    Re: Problem Storing Object

    Quote Originally Posted by yudlugar View Post
    You've defined colPayCollection as a collection and then your setObj asked for an object. I'm not really sure if it's the issue as I'd need the full code to debug it but I'd guess:
    Sub setObj(key As String, var As Collection)
    or
    Sub setObj(key As String, var As variant)

    Edit: changed my mind, don't think that is the issue anymore.. it might be something to do with variable types if it asks for an object when you try and call setObj...

    Upload your full code please.
    Yeah tried that but still get the same thing regardless of whether I change it to a variant or collection - it still says object required/expected.

    @OllieB it fails on the "call csession.setobj" line - like I say I've used this exact code in VB6 before so I know it worked there.

    Ive attached a file with the requisite code in it - thanks for the help guys.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Problem Storing Object

    Can you upload again - I think that is a blank file (8.2kb?)

  8. #8
    Registered User
    Join Date
    10-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Office Pro 2010
    Posts
    6

    Re: Problem Storing Object

    The excel portion is blank but the Visual Basic code is there and can be run. I can use a different format if you prefer?

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Problem Storing Object

    The VBA project is blank for me as well. Guess it might be a version thing but it usually converts it ok.

  10. #10
    Registered User
    Join Date
    10-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Office Pro 2010
    Posts
    6

    Re: Problem Storing Object

    Here's the xlsb - hopefully should be able to open in the project ?
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Problem Storing Object

    Can't see anything obvious, might need a bit of time with this one.

    One thing is that I don't think exists() is a vba function. I'm assuming you want the dictionary object version so you probably need to replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Edit: Again - ignore that post! Didn't look at all the code properly.

    I think Izandol has got it though, if I copy and paste your csession code into the standard module it runs fine.
    Last edited by ragulduy; 10-09-2013 at 10:27 AM.

  12. #12
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Problem Storing Object

    Where do you instantiate csession? It does not have auto-instancing in VBA.

  13. #13
    Registered User
    Join Date
    10-09-2013
    Location
    United Kingdom
    MS-Off Ver
    Office Pro 2010
    Posts
    6

    Re: Problem Storing Object

    Quote Originally Posted by Izandol View Post
    Where do you instantiate csession? It does not have auto-instancing in VBA.
    Oh SNAP! I did not know that but you seem to have hit the nail right on the head as declaring it globally before the sub has begun has resolved the problem!

    Thanks to all of you for the help with this ! I knew it was probably something simple I'd missed but couldn't see the wood for the trees.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Textbox & Object problem
    By jasondu in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-11-2012, 02:32 PM
  2. Problem with updating IE object
    By mhtkhan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2012, 02:40 PM
  3. data storing problem in worksheet
    By pradeepkumar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2010, 03:37 AM
  4. Range object problem in VBA
    By pani_hcu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-26-2009, 11:33 PM
  5. Object Variable Not Set Problem
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-21-2008, 10:45 AM

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