View Full Version : Using VBA with Microsoft Word to create questionairre!
ITstudent2006
Apr 28, 2009, 08:59 AM
We scrapped the Acrobat approach as we found out you cannot control what is exported. We decided on trying to use Visual Basics for Applications and creating Macros that can be used in M$ Word. If we cannot get this to work our last option is Using Straight Visual Basic but the maintenance is a considerable amoount more so that is our last resort.
What we want to do is have a word doc. That displays a list of questions. These questions are then gone through and ticked if wanted and not ticked if not wanted. After these questions have been gone through there will be an action button that submits the ticked questions along with a header to a new page where it will print off for use by the intended individual.
If anyone has any suggestions or other ways we could go about doing this please let us know ASAP.
Thanks in Advance
Rick
Perito
Apr 28, 2009, 09:03 AM
You will be able to do this using VBA. It shouldn't be a big deal, if you have someone who is sufficiently competent in VBA or at least a programmer who can learn it. You can create forms in VBA, and it sounds like all you need is a bunch of checkboxes.
ITstudent2006
Apr 28, 2009, 09:40 AM
Correct. We've got the main part figured out. We have created the form with little resistance. The only question I have is after this list is gone through and the questions are decided upon. We want the chosen questions along with the default header to be sent to a new page. This new page will have only the questions that were ticked and the default header. Thus, the individual can use this second page to do with what was intended.
Thank you for your response perito.
I am just researching how; in VBA, to transfer text from one document to another. Like mentioned above!
Rick
Perito
Apr 28, 2009, 09:45 AM
One trick I use (when I'm working with VBA -- not my favorite language) is to create a macro and then examine the macro code to see how it was done. I then copy that code to my own subroutines and delete the macro.
The Visual Basic in Office 2007 is different from the VBA used in earlier versions of the product. I think that 2007 will work with code written in previous versions. Nevertheless, it's something you should keep in mind for the future.
ScottGem
Apr 28, 2009, 10:00 AM
I agree with Perito on VBA code for Word or Excel. Create a macro by capturing the keystrokes you use to manually complete the task then look at the generated code and modify it.
But you still won't be able to create an executable. The user will need Word to open the file and fill it in. You should also be sending the user a DOT file, not a DOC. The user will then need to save the document as a DOC.
Put if what you are trying to do is have users fill in a survey and collect the results can I suggest two alternatives; www.surveymonkey.com (http://www.surveymonkey.com) as one. For the other, if all the users are using Office 2007, you can use Access to create an e-mail form, send it via Outlook and have the user fill in the form and return it. The filled in data can then be automativcally added to the Access table.
ITstudent2006
Apr 28, 2009, 10:00 AM
This is exactly what I need.
I need the code for VBA to transfer text from the current document to a new document. Both documents will be M$ Word. I'm looking all over and can't seem to find it. (I am new to VB and VBA)
Perito,
I am not the lead on this, I will show him your idea. Thanks so much for the response.
Rick
ScottGem
Apr 28, 2009, 10:03 AM
If you send the questionairre as a DOT, the user will have to create a new document to save it.
ITstudent2006
Apr 28, 2009, 10:03 AM
Here's what it is for.
I am with my brother who is the Systems Admin. For an insurance company.
The producers of this company would like a list of questions they can go through and select and then print to take to their potnetial clients. The questions very on the prospected company as well as what type of insurance. This list is essentially a databse of all the questions that the producers can then go through select the appropriate Q's they need for their current job and then print only the questions selected.
Rick
ScottGem
Apr 28, 2009, 10:05 AM
Ahh, I see. When they create this list of questions are they connected to the company network?
ITstudent2006
Apr 28, 2009, 10:06 AM
Yes, my brother will put it on one of the local drives to be used by those with rights to that drive (all the producers)
ScottGem
Apr 28, 2009, 10:09 AM
Then I would use a Database for this. Create a database of the questions, include a field to select the question. Then print a report listing only the selected questions. After printing clear the select field. If you need to you can keep track of the selected questions for each instance.
ITstudent2006
Apr 28, 2009, 10:15 AM
Well we've got the form already made, by chance are you familiar with VBA syntax
ScottGem
Apr 28, 2009, 10:19 AM
Not so much with Word.
ITstudent2006
Apr 28, 2009, 10:21 AM
OK, thanks for the responses though. I'll keep everyone updated for the sake of self-learning
Rick
ITstudent2006
Apr 28, 2009, 11:22 AM
We got it.
We found the coding for it!
Thanks to all who responded!
Rick