x404.co.uk
http://www.x404.co.uk/forum/

Tables in MS Word help - macro/VB
http://www.x404.co.uk/forum/viewtopic.php?f=3&t=16394
Page 1 of 1

Author:  cloaked_wolf [ Tue May 08, 2012 5:36 pm ]
Post subject:  Tables in MS Word help - macro/VB

Posted here for max exposure.

I'm trying to create a document in MS Word 2003 (what they use at work) with the idea being that if required, it can be loaded, filled and saved. Part of this means creating a form. What I'd like to do in the form is create either checkboxes or dropdown fields. The value of the field is recorded and basically a total score given.

For example, a depression questionnaire. The selectable answers would be: not at all, some days, most days, every day.

The questions would be:

1. I feel low...
2. I have little interest in doing things...
3. Poor appetite...

The idea is that 'not at all' = 0, 'some days' = 1, 'most days' = 2, 'every day' = 3. The scores are added up and a final score is given.

I've managed to create a table in Word, filled in the questions and created dropdown boxes for the answers with the options given above. What I need is for the next column to display a score based on the answers given and then give a total score at the bottom.

Any ideas on how to do this? It needs to be Word 2003 as it is launched from another program and the document is then saved within that program so the results can be seen at any time.

Author:  cloaked_wolf [ Tue May 08, 2012 10:19 pm ]
Post subject:  Re: Tables in MS Word help - macro/VB

Okay so a pic to show what I'm after:

Image

The first pic shows what the options are. In my head, each one has a score:
Not at all = 0
Several days = 1
More than half the days = 2
Nearly every day = 3

The far right cell should have the value based on what was selected in the middle cell. Total should then sum up the above cells and display a total!

I've looked into this and it goes beyond my programming skills. I've bugger all idea on how to achieve what I want and my google fu hasn't been helpful.

Author:  finlay666 [ Wed May 09, 2012 8:44 am ]
Post subject:  Re: Tables in MS Word help - macro/VB

Should be able to do it with just conditional formatting to output a value, then sum the values, probably no programming involved

Author:  EddArmitage [ Wed May 09, 2012 8:55 am ]
Post subject:  Re: Tables in MS Word help - macro/VB

finlay666 wrote:
Should be able to do it with just conditional formatting to output a value, then sum the values, probably no programming involved

That's using Excel, non?

Is there any reason for the requirement for it to be an MS Word solution?

Author:  cloaked_wolf [ Wed May 09, 2012 8:57 am ]
Post subject:  Re: Tables in MS Word help - macro/VB

It's in word rather than excel so it doesn't seem to accept formulae or values (unless I'm doing something silly?).

I've done some research last night and so far this is what I've come up with:

Code:
Sub AddDropDownResults()



Dim Dropdown1, Dropdown2, Dropdown3, Dropdown4, Dropdown5, Dropdown6, Dropdown7, Dropdown8, Dropdown9 As Integer

Dropdown1 = Val(ActiveDocument.FormFields("DropDown1").Result)

Dropdown2 = Val(ActiveDocument.FormFields("DropDown2").Result)

Dropdown3 = Val(ActiveDocument.FormFields("DropDown3").Result)

Dropdown4 = Val(ActiveDocument.FormFields("DropDown4").Result)

Dropdown5 = Val(ActiveDocument.FormFields("DropDown5").Result)

Dropdown6 = Val(ActiveDocument.FormFields("DropDown6").Result)

Dropdown7 = Val(ActiveDocument.FormFields("DropDown7").Result)

Dropdown8 = Val(ActiveDocument.FormFields("DropDown8").Result)

Dropdown9 = Val(ActiveDocument.FormFields("DropDown9").Result)

ActiveDocument.FormFields("Text10").Result = Str(Dropdown1 + Dropdown2 + Dropdown3 + Dropdown4 + Dropdown5 + Dropdown6 + Dropdown7 + Dropdown8 + Dropdown9)

End Sub



What I need to do is now give values to each dropdown entry as stated in the previous post. Still looking into doing this. Once this is done, it may well work. I hope!

Author:  cloaked_wolf [ Wed May 09, 2012 8:59 am ]
Post subject:  Re: Tables in MS Word help - macro/VB

EddArmitage wrote:
Is there any reason for the requirement for it to be an MS Word solution?

Yes. The program I use is the one for medical records. It can tie in with MS Word so I've managed to create an asthma leaflet which when loaded, is filled in with the patient's name, recent lung tests and medications (which can then be used to explain which medications are for asthma, and what the best lung test result is). It won't tie in with excel and that's down to the original program and is not something I can change.

Author:  finlay666 [ Wed May 09, 2012 11:45 am ]
Post subject:  Re: Tables in MS Word help - macro/VB

EddArmitage wrote:
finlay666 wrote:
Should be able to do it with just conditional formatting to output a value, then sum the values, probably no programming involved

That's using Excel, non?

Is there any reason for the requirement for it to be an MS Word solution?

I thought you could use the two, had to insert it as an Excel spreadsheet though, but was a long time since I did that though (if you can still do it)

Author:  cloaked_wolf [ Wed May 09, 2012 2:41 pm ]
Post subject:  Re: Tables in MS Word help - macro/VB

I think you can embed a spreadsheet but that's different to a table in Word. A table is literally that - some lines. The "cells" are just boxes. No formulae/calculations.

I think it needs to be considered as a form in a Word document, rather than a (excel) table.

Author:  big_D [ Thu May 10, 2012 4:33 am ]
Post subject:  Re: Tables in MS Word help - macro/VB

Tables in Word can have simple formulas in them.

Author:  cloaked_wolf [ Fri May 11, 2012 1:09 pm ]
Post subject:  Re: Tables in MS Word help - macro/VB

*hits head*

Playing around and I found out the document has to be saved as an RTF so no macros. :(

Means I'll have to find other ways of doing this.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/