You can use CWinApp::GetFirstDocTemplatePosition()
and CWinApp::GetNextDocTemplate()
to iterate through the doc templates.
Then, for each doc template, use CDocTemplate::GetFirstDocPosition()
and CDocTemplate::GetNextDoc()
to iterate through the documents.
You will need to make the document data public or provide getters/setters.