+ Reply to Thread
Results 1 to 12 of 12

NULL pointer problem Error=[0x80040204]

  1. #1
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Red face NULL pointer problem Error=[0x80040204]

    Hi, there
    I am trying to transfer data from Access to Excel. For a same piece of code, it is ok at first run but not the following runs. This error appears. Excel behaves OK after Click “OK”. The code has problem is “excWorkbook.Close”. Any suggestions will be highly appreciated.
    Thanks
    Lily.
    Last edited by SpringLily; 05-05-2011 at 08:54 AM. Reason: Solved!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: NULL pointer problem Error=[0x80040204]

    It would be helpful if you posted your code for analysis.

    What are you trying to transfer to Excel. A Query? Table?

    Are you using the transferspreadsheet function?

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: NULL pointer problem Error=[0x80040204]

    Not a table or quary yet. Only some data from Access. Please see below. Thanks.
    Please Login or Register  to view this content.
    Last edited by romperstomper; 05-10-2011 at 03:44 AM. Reason: forgot some important information

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: NULL pointer problem Error=[0x80040204]

    Firstly, I am not an Excel VBA expert. I do use code in Access to facilitate its use.

    Specifically, what data are you trying to move from Access to Excel? Will the data be in a table or extracted from a table to a query? This is really important to know. There are built in functions that let you do that. Additionally, if you want to automate, there are some simple export codes that can be written in Access to do that.

    Perhaps, if I understood what your objective was, then I might be able to help you.

    Alan

  5. #5
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: NULL pointer problem Error=[0x80040204]

    Hi, Alan
    I use Access as my application front end for user to input some data, then some of the inputted data will be transfered to an Excel file, which is predefined with certain NAMES. The Excel part of the code is OK until the line "excWorkbook.Close". My guts feeling is that something in the objects for Access and Excel application are used wrong, but I don't know what. The data I am trying to transfer to Excel is stored in a table, However, in the code above, I setup some dummy data for "Product" and "Standerd", which would be extracted from a table, just want to try if the code works OK.

    Could you please help. Thanks. Regards, Lily
    Last edited by SpringLily; 05-04-2011 at 03:27 PM.

  6. #6
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: NULL pointer problem Error=[0x80040204]

    hi,

    I agree with Alan, one of the types of inbuilt functionality is likely to be suitable for your task. What is your data?

    In saying that, here's an attempted modification of your code.
    Note, this is untested because I don't have access to a VBE at the moment, and it may also cause some errors, if I I've been too zealous in my commenting out unnecessary/incorrect (?) code. It may give you some ideas. I have reworded the code to always use a new instance of excel, while this may not be as memory efficient, I can say that it won't interfere with any existing work that you may be doing in excel (in parellel to running the Accss code).



    Please Login or Register  to view this content.
    I have my fingers crossed...

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  7. #7
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: NULL pointer problem Error=[0x80040204]

    Sorry, I just read your last post properly.

    Here's a link to a copyfromrecordset example that can pull data from an Access table, this would need some changes made, but you may be able to merge it with my suggestions...
    http://www.exceltip.com/st/Import_da...Excel/428.html

    hth
    Rob

  8. #8
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: NULL pointer problem Error=[0x80040204]

    Hi, Rob
    Thanks a lot. It works! Additionally, there is no error when the Excel files manipulated through Access is re-opened. Everything works perfectly. Regards, Lily.
    Last edited by SpringLily; 05-05-2011 at 08:53 AM.

  9. #9
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: NULL pointer problem Error=[0x80040204]

    hi Lily,

    Thanks for the feedback, adding to my rep' and marking the thread as Solved :-)

    Rob

  10. #10
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: NULL pointer problem Error=[0x80040204]

    Hi, Rob
    Thanks for your advice and the link you recommended. I did use some code in the link to write my code for transferring date from Access to Excel. By the way, could you please explain to me why mine has the error and yours doesn't. It puzzled a lot. Thanks in advance. Your answer will be highly appreciated.

    Regards,
    Lily

  11. #11
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: NULL pointer problem Error=[0x80040204]

    hi Lily,

    I'm sorry, this isn't really an answer but it may help.

    When I read your last post I thought, "oh, that's easy, it's because you have some excel object references that aren't explicitly defined all the way up to the xlApp reference". However, then I went back to re-read your code to get the exact line where that would be occurring & I couldn't see any object (eg range/worksheet/workbook) references that didn't have explicit referencing to the xlApp level. So... I think it will relate to your use of "GetObject". The following link may help you understand more about how Getobject works: http://www.excelforum.com/excel-prog...utomation.html


    hth
    Rob

  12. #12
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: NULL pointer problem Error=[0x80040204]

    Thanks, Rob. It is helpful. Regards, Lily

+ Reply to 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