- Local time
- Yesterday, 20:57
- Joined
- Feb 28, 2001
- Messages
- 28,642
I apologize for the size of this post, but it is giving me fits as I try to wrap up a project and suddenly have hit a massive roadblock. It is a complex problem and I'm a hair's breadth away from finishing it, only to find ... :banghead:
Looking for some advice on how to proceed after getting this error:
#1004, Application-defined or object-defined error
Here's the context:
I've been working on a genealogy project. The overview is that I download and parse out some GEDCOM formatted data, analyze it, and identify relationships among various persons who are direct ancestors or family members of direct ancestors. At the moment, my database for this lists over 950 persons. The parsing and relationship analysiss parts work, and any of my headaches there are simply because the older the records, the less exact they are and thus are harder to analyze and get consistency among those old records. That is NOT my complaint for this post, but it is necessary to know for the context.
Where I come into grief is in building a presentation of the results of that analysis.
I am using Access VBA to drive the generation of a spreadsheet that will show what I have found using a Family-Tree type of diagram, which technically is a SmartArt "Horizontal Hierarchy" in style. I am dealing with an Excel Application Object, workbooks, and worksheets being driving from Access VBA. I do that because the analysis of the GEDCOM data is done in Access and doing this manually for a ten-generation family tree is, how shall I say it? Prohibitively tedious.
In my approach, I have this workbook that contains a template worksheet that contains a bit of "Smart Art" graphics - more specifically the Horizontal Hierarchy in which I have a SmartArt node for the "anchor" of the family tree plus two SmartArt nodes for the parents plus four SmartArt nodes for the grandparents. The only worksheet in the template file contains the SmartArt object on a single worksheet named "Template".
The intent of the design is that when I create this diagram, I start by copying the template file and then open the copy. I next find the sheet named "Template" and copy it. Then I rename the copy to "Page n" where "n" is determined by a simple counter. After that, I start filling in the data for the starting person, that person's parents, and then the grandparents. Seven persons per page covering three generations. And the name, date of birth, and date of death DO get filled in.
If I know anything about my great-grandparents (and I often DO know something, actually), then I create a second sheet starting from the grandparent and show THAT ancestor's family tree. I add some notes in various cells on the first sheet to say "more about grandpa on sheet 2" and a similar node pointing backwards saying "more about great-grandpa's kids on page 1."
The routine that does this is recursive. I give it a starting point and it generates pages to show (person, parents, grandparents) on a page and then finds out if I know more about the grandparents' ancestry from THAT page. If so, I recursively call the page generator.
This actually generates five worksheets this way. But where I hit the wall - and the subject error - is that when the recursion returns to its caller, I start getting that error 1004. After the recursion return, something so simple as a
xWrkSht.Range("A13") = "some text"
stops working, even though BEFORE the recursion that same syntax worked for a different selected cell, both on the same sheet and on its predecessor. After the error, I can't manipulate ANYTHING. It just reaches some point and stops working entirely.
Once the code exits and all the recursion is resolved (through error returns, unfortunately), the code closes the workbook. At that point I can open the workbook directly from Excel and see that it really DID build a bunch of stuff. The names and dates are there.
I have searched the web for that error and found some notes that suggest this is a known problem related to the idea that I am copying the template worksheet and then working on the copy. One suggested workaround is to every so often just close & save the workbook, reset the object variable to Nothing, and then re-open the workbook. That doesn't appear to work. I can do this in the recursion routines because I am using "ByRef" argument passage for the Excel-based objects.
Has anyone ever run across the "Error 1004" problem working with Excel? Were you able to find a working solution? If I can get it to keep on working then I can finish the presentation part and focus on the few errors I still have in the parsing and analysis parts.
Apologies again for the size of the post, but it isn't a trivial project.
Looking for some advice on how to proceed after getting this error:
#1004, Application-defined or object-defined error
Here's the context:
I've been working on a genealogy project. The overview is that I download and parse out some GEDCOM formatted data, analyze it, and identify relationships among various persons who are direct ancestors or family members of direct ancestors. At the moment, my database for this lists over 950 persons. The parsing and relationship analysiss parts work, and any of my headaches there are simply because the older the records, the less exact they are and thus are harder to analyze and get consistency among those old records. That is NOT my complaint for this post, but it is necessary to know for the context.
Where I come into grief is in building a presentation of the results of that analysis.
I am using Access VBA to drive the generation of a spreadsheet that will show what I have found using a Family-Tree type of diagram, which technically is a SmartArt "Horizontal Hierarchy" in style. I am dealing with an Excel Application Object, workbooks, and worksheets being driving from Access VBA. I do that because the analysis of the GEDCOM data is done in Access and doing this manually for a ten-generation family tree is, how shall I say it? Prohibitively tedious.
In my approach, I have this workbook that contains a template worksheet that contains a bit of "Smart Art" graphics - more specifically the Horizontal Hierarchy in which I have a SmartArt node for the "anchor" of the family tree plus two SmartArt nodes for the parents plus four SmartArt nodes for the grandparents. The only worksheet in the template file contains the SmartArt object on a single worksheet named "Template".
The intent of the design is that when I create this diagram, I start by copying the template file and then open the copy. I next find the sheet named "Template" and copy it. Then I rename the copy to "Page n" where "n" is determined by a simple counter. After that, I start filling in the data for the starting person, that person's parents, and then the grandparents. Seven persons per page covering three generations. And the name, date of birth, and date of death DO get filled in.
If I know anything about my great-grandparents (and I often DO know something, actually), then I create a second sheet starting from the grandparent and show THAT ancestor's family tree. I add some notes in various cells on the first sheet to say "more about grandpa on sheet 2" and a similar node pointing backwards saying "more about great-grandpa's kids on page 1."
The routine that does this is recursive. I give it a starting point and it generates pages to show (person, parents, grandparents) on a page and then finds out if I know more about the grandparents' ancestry from THAT page. If so, I recursively call the page generator.
This actually generates five worksheets this way. But where I hit the wall - and the subject error - is that when the recursion returns to its caller, I start getting that error 1004. After the recursion return, something so simple as a
xWrkSht.Range("A13") = "some text"
stops working, even though BEFORE the recursion that same syntax worked for a different selected cell, both on the same sheet and on its predecessor. After the error, I can't manipulate ANYTHING. It just reaches some point and stops working entirely.
Once the code exits and all the recursion is resolved (through error returns, unfortunately), the code closes the workbook. At that point I can open the workbook directly from Excel and see that it really DID build a bunch of stuff. The names and dates are there.
I have searched the web for that error and found some notes that suggest this is a known problem related to the idea that I am copying the template worksheet and then working on the copy. One suggested workaround is to every so often just close & save the workbook, reset the object variable to Nothing, and then re-open the workbook. That doesn't appear to work. I can do this in the recursion routines because I am using "ByRef" argument passage for the Excel-based objects.
Has anyone ever run across the "Error 1004" problem working with Excel? Were you able to find a working solution? If I can get it to keep on working then I can finish the presentation part and focus on the few errors I still have in the parsing and analysis parts.
Apologies again for the size of the post, but it isn't a trivial project.