bentheimmigrant
Lost & confused
- Local time
- Today, 19:35
- Joined
- Aug 21, 2015
- Messages
- 60
So, I have been tasked with generating reports in Word if possible. There are multiple reasons for this, but primarily they are the need to a) have equations and various nice looking things in the report, b) be built by non-access people for me to then set up the database connections with (because I simply don't have the time to build these reports from scratch), and c) be editable post-creation by non-access people.
I've figured out how to do this generally, and have in the past used content controls (CC in the code below), and the generic code:
However, what I will have to do is effectively generate various types of subreports, some of which will be called, some of which won't, with some being called multiple times.
So a main report may be populated with report type A, B, C, and D, but it will look more like A1, B1, B2, B3, C1, B4, B5, B6, D1, B7. Each instance of the sub-reports will be populated by a different record (with a field determining which type to use).
How would you approach this challenge? Unfortunately most of my VBA knowledge is Excel and Access, so I'm not really up to speed on how much I can bend Word to my will (may have to force their hand and push for Excel reports, as then I can just copy template sheets and fill certain cells, but I'd rather do what I'm asked).
I suspect the only really viable option is to open a new instance for each subreport, and then copy contents into a main report. That or programmatically create a master document (yikes!). But I would love to hear otherwise.
I've figured out how to do this generally, and have in the past used content controls (CC in the code below), and the generic code:
Code:
For Each CC In wDoc.ContentControls
If CC.Title = TargetName Then CC.Range.Text = TargetText
Next CC
However, what I will have to do is effectively generate various types of subreports, some of which will be called, some of which won't, with some being called multiple times.
So a main report may be populated with report type A, B, C, and D, but it will look more like A1, B1, B2, B3, C1, B4, B5, B6, D1, B7. Each instance of the sub-reports will be populated by a different record (with a field determining which type to use).
How would you approach this challenge? Unfortunately most of my VBA knowledge is Excel and Access, so I'm not really up to speed on how much I can bend Word to my will (may have to force their hand and push for Excel reports, as then I can just copy template sheets and fill certain cells, but I'd rather do what I'm asked).
I suspect the only really viable option is to open a new instance for each subreport, and then copy contents into a main report. That or programmatically create a master document (yikes!). But I would love to hear otherwise.