PDA

View Full Version : Creating recordset from Excel data in VBA Word



MrHanky
11-12-2008, 07:40 AM
Hi,

Im new to using VBA in Word and am just tryng to do the following. I have had a search on here but think my man issue is that im not overly sure onwhat I shoud besearchn for. I do have some experience of using VBA in Access but so far am finding it a bit different.
Any help or pointers as to what I should be looking for are appreciated.

Task:

I have a Word document that is used as a form for users to fill in. On this form there are various check boxes and combo boxes.

I also have an Excel worksheet which is a matrix of data to cross reference check boxes on Word form against. So if checkbox1 is checked that means I should pull data from the Excel sheet where Column A = 4.1 (thats my example anyway).

So basically I would ideally like to click a button Word, go through the form and cross reference it against the Excel sheet and then print to a seperate document all of the results.

I have so far managed to open the Excel sheet from Word VBA, read a line and evaluate it. I also know how to loop through the worksheet to check all data. The part I am struggling to understand, is how I can then store the results for each evaluated line that meets my criteria. So I essentially build up a table of results in VBA, and then print the results to a new Word document.

I hope this makes sense to someone and would really appreciate some pointers.

Thanks

Mark

lucas
11-12-2008, 10:14 AM
Hi Mark,

see if this kb entry give you any help. Maybe use a click event on the listbox to select the data. I don't fully understand your requirment but thought I would offer this as a starting point.

http://vbaexpress.com/kb/getarticle.php?kb_id=179

MrHanky
11-13-2008, 07:29 AM
Thanks very much Lucas. That looks as if it might be a good starting point for my requirement.

Thanks again

Mark


Hi Mark,

see if this kb entry give you any help. Maybe use a click event on the listbox to select the data. I don't fully understand your requirment but thought I would offer this as a starting point.