asifbaig
10-28-2011, 07:48 AM
Hi folks. I've written a small program for purposes of medical reporting that creates a new document based on a template and fills in the patient data that it has been given from a form. At the end of the document, it is supposed to write the names of the consultants who are going to sign the report, along with their designation/degrees etc. The name has to appear in bold and the qualifications in a smaller, non-bold font.
To that end, I created a borderless table near the end of document and made the program load the names of the consultants from "seniorlist.doc" which had a single table containing the names/degrees of seniors with the proper formatting already applied. The plan is to pick up the entire contents of a cell and put them in the document that is being created. What command should I use so that the formatting is preserved?
This is not, however, the reason for this post. Once a report has been created, I would like the names of the consultants to be changeable so I created a form and attached it to the Normal template, making it available in every document. This form examines that borderless table in the current document and displays its contents. Along the side, it loads the names from that "seniorlist.doc" file and displays them in a listbox making it easy to pick names from the entire list.
Now the problem, and the reason for the topic, is that in order to load the names from seniorlist.doc, the file has to be opened, with its own window appearing in the taskbar (at least I think so). And seniorlist.doc has to be closed when the names have been inserted (so I added that command in the "Change Consultants" button) but if someone changes their mind and closes the dialogue by pressing the red X close button, the seniorlist.doc will remain open.
Considering the average computer literacy of the people who will be using this program, I'd like some alternative instead of exposing my program's vital components for accidental editing.
So I wondered:
1. Is there a way to save the formatted text in a variable? In that case, all I'd have to do is to open the seniorlist.doc once, load all the names and degrees in an array and close it, then use the array to populate the listbox as well as replace names.
OR
2. Is there a way to attach hidden text to a document that can be accessed by code but not easily visible to the average user? Kind of like having a separate workbook in Excel (perhaps called a wordbook ;) )? That way, upon the generation of a new report, I could throw the list of consultants in that second "wordbook", load it from there instead of using a separate seniorlist.doc file and since the wordbook would be hidden, it would not confuse the average user nor appear when printing that report.
OR
3. Finally, and most importantly, the reason I went into such detail about the working and purpose of the program is to know if there's a better and simpler way of doing what I am doing. I've not had much experience with VBA, only with QBasic back in the time of DOS, and I still find myself trying to solve programmatic problems with the methods I learnt in that ancient time.
I hope the details I provided were not confusing. Please tell me if any portion needs elaboration.
To that end, I created a borderless table near the end of document and made the program load the names of the consultants from "seniorlist.doc" which had a single table containing the names/degrees of seniors with the proper formatting already applied. The plan is to pick up the entire contents of a cell and put them in the document that is being created. What command should I use so that the formatting is preserved?
This is not, however, the reason for this post. Once a report has been created, I would like the names of the consultants to be changeable so I created a form and attached it to the Normal template, making it available in every document. This form examines that borderless table in the current document and displays its contents. Along the side, it loads the names from that "seniorlist.doc" file and displays them in a listbox making it easy to pick names from the entire list.
Now the problem, and the reason for the topic, is that in order to load the names from seniorlist.doc, the file has to be opened, with its own window appearing in the taskbar (at least I think so). And seniorlist.doc has to be closed when the names have been inserted (so I added that command in the "Change Consultants" button) but if someone changes their mind and closes the dialogue by pressing the red X close button, the seniorlist.doc will remain open.
Considering the average computer literacy of the people who will be using this program, I'd like some alternative instead of exposing my program's vital components for accidental editing.
So I wondered:
1. Is there a way to save the formatted text in a variable? In that case, all I'd have to do is to open the seniorlist.doc once, load all the names and degrees in an array and close it, then use the array to populate the listbox as well as replace names.
OR
2. Is there a way to attach hidden text to a document that can be accessed by code but not easily visible to the average user? Kind of like having a separate workbook in Excel (perhaps called a wordbook ;) )? That way, upon the generation of a new report, I could throw the list of consultants in that second "wordbook", load it from there instead of using a separate seniorlist.doc file and since the wordbook would be hidden, it would not confuse the average user nor appear when printing that report.
OR
3. Finally, and most importantly, the reason I went into such detail about the working and purpose of the program is to know if there's a better and simpler way of doing what I am doing. I've not had much experience with VBA, only with QBasic back in the time of DOS, and I still find myself trying to solve programmatic problems with the methods I learnt in that ancient time.
I hope the details I provided were not confusing. Please tell me if any portion needs elaboration.