+ Reply to Thread
Results 1 to 6 of 6

How to extract data from Excel database to create word report for each patient

  1. #1
    Registered User
    Join Date
    07-05-2014
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    9

    How to extract data from Excel database to create word report for each patient

    Hi guys,

    I'm looking for a way to pull some data from my Excel database to create a word report. Basically, each row in Excel equals to one patient. Each column is a variable regarding that patient, i.e. pretty elementary stuff.

    I've made a Word template, but I'd like to find a way to automatically populate the data in the Word report so I can print it easily and add it to the file (see the screenshot, it'll be much clearer).

    I guess there is some kind of macros that could save me the hassle of manually finding each value for each and every patient, but I'm struggling as to where to start... Am I seeing this the wrong way? Do I need to start from Excel and output the data into a pre-defined template, i.e.the word report?

    Any help?

    Regards,
    Max

    Screenshot of what I'm trying to do :


    ps: I cross-posted this in a word forum but I didn't get any help and I thought I was better off posting this in this Excel forum. Also, I only found people trying to do the opposite of what I want to do.
    Last edited by nightale; 07-10-2014 at 04:14 PM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: How to extract data from Excel database to create word report for each patient

    Welcome to the board!

    Check out Mail Merge inside of Word.

    There are also several good videos on Youtube explaining it.

    Please include the link to other forums if you cross post.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    07-05-2014
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    9

    Re: How to extract data from Excel database to create word report for each patient

    Ok thanks. I'll look into that but I'm not sure why the "Mailings" tab is relevant for what I need to do, that seems a bit counter-intuitive. In fact, since I don't have "recipients", do I need to indicate my subject numbers instead of recipients? Any link for something more related to what I'm trying to do?

    Thanks!

    PS: cross-post is on : http://www.msofficeforums.com/word/2...eate-word.html

    Edit : just tried and it seems that "recipient" can be replaced with "patient" in my case. It seems to work, but my problem is that it only import a part of my columns. I have 706 variables and it seems to import only 240 columns of data. Any way around that?
    Last edited by nightale; 07-05-2014 at 04:54 PM.

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: How to extract data from Excel database to create word report for each patient

    Apparently that's the limit. (Learned something new today.)

    There seems to be a workaround, but I've never tried it.

  5. #5
    Registered User
    Join Date
    07-05-2014
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    9

    Re: How to extract data from Excel database to create word report for each patient

    Thanks. It does work, although it doesn't show all the columns in the wizard, they all show up as available to include in the word report. However, for some reason, it add an empty record every other recipient number (1 is ok, 2 is empty, 3 is ok, 4 is empty, etc.). It must be a conversion artifact from the CSV (comma separated) conversion. I unchecked these empty cases and now when I browse through my recipients, it goes from 1, to 3, to 5, etc (so patient 001, patient 002, patient 003). I guess that's good enough for what I need, thank you.

  6. #6
    Registered User
    Join Date
    05-16-2012
    Location
    dallas, texas
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: How to extract data from Excel database to create word report for each patient

    I am a beginner with this macro stuff. I was wanting to do same kind of thing... In Excel I had 6 rows of customers with 7 columns of Data... First sheet is called "data" created 2nd sheet called "template" And set it up with name of matching columns on first sheet, (so in Column A on Template is Name in Cell A3 , address in A4 etc.. then figured the data from first sheet goes to B3, B4, etc.) it creates a word doc for each customer, then saves it as the customer name. This is my code if you can use and rewrite it to match your columns and cells

    Sub ControlWord()
    Dim appWD As Word.Application
    ' Create a new instance of word & make it visble
    Set appWD = CreateObject("Word.Application.15")
    appWD.Visible = True

    Sheets("Data").Select
    'Find the last row with data in the database
    finalRow = Range("A25").End(xlUp).Row
    For i = 2 To finalRow
    Sheets("Data").Select
    ' Copy the name to cell B3
    Range("A" & i).Copy Destination:=Sheets("Template").Range("B3")
    ' copy the data columns, transpose and paste in B4:B9
    Range("B" & i & ":G" & i).Copy
    Sheets("Template").Select
    Range("B4").PasteSpecial Transpose:=True
    ' Copy the data for the new document to the clipboard
    Range("A2:H10").Copy
    ' tell word to create a new document
    appWD.Documents.Add
    ' tell word to paste the contents of the clipboard into the new document
    appWD.Selection.Paste
    ' save the new document with a sequential file name
    appWD.ActiveDocument.SaveAs Filename:=Sheets("Data").Range("A" & i).Value
    ' close this new word document
    appWD.ActiveDocument.Close
    Next i
    ' Close the Word application
    appWD.Quit


    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 04-21-2014, 03:42 PM
  2. How to extract weekly data and create a report using VBAs
    By Roselalala in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-09-2013, 11:30 AM
  3. VBA script to extract simple data from test list to create report.
    By weekendMajor in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-26-2012, 02:52 AM
  4. Replies: 0
    Last Post: 02-14-2012, 12:31 PM
  5. Matching patient personal data to that already stored in a database
    By helenjwheeler in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-18-2009, 02:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1