Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
Shawn Shawn is offline
external usenet poster
 
Posts: 21
Default How to import data from Excel into a Word doc

I'm sure there's a simple solution, but I cannot find out how to do the
following. I am populating different fields in a Word doc and would like to
pull the data from specific cells in an Excel file. I do this many times
using the same Word and Excel template, so I would also like to be able to
change the "source" Excel file as you can when pulling data from one Excel
file to another.

By the way I am running Office 2007 and Vista. Thanks in advance for your
help!!

Shawn
  #2   Report Post  
Posted to microsoft.public.word.newusers
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default How to import data from Excel into a Word doc

The following macro will probably do what you require.

' Macro created 26/10/01 by Doug Robbins to update links in a document
'
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer, linkcode As Range
Dim Message, Title, Default, Newfile
Dim counter As Integer



counter = 0
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldLink Then

Set linkcode = alink.Code
i = InStr(linkcode, Chr(34))
Set linktype = alink.Code
linktype.End = linktype.Start + i
j = InStr(Mid(linkcode, i + 1), Chr(34))
Set linklocation = alink.Code
linklocation.Start = linklocation.Start + i + j - 1
If counter = 0 Then
Set linkfile = alink.Code
linkfile.End = linkfile.Start + i + j - 1
linkfile.Start = linkfile.Start + i
Message = "Enter the modified path and filename following this
Format " & linkfile
Title = "Update Link"
Default = linkfile
Newfile = InputBox(Message, Title, Default)
End If
linkcode.Text = linktype & Newfile & linklocation
counter = counter + 1
End If
Next alink


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Shawn" wrote in message
...
I'm sure there's a simple solution, but I cannot find out how to do the
following. I am populating different fields in a Word doc and would like
to
pull the data from specific cells in an Excel file. I do this many times
using the same Word and Excel template, so I would also like to be able to
change the "source" Excel file as you can when pulling data from one Excel
file to another.

By the way I am running Office 2007 and Vista. Thanks in advance for your
help!!

Shawn



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import data from Excel to Word Robbo Microsoft Word Help 1 August 27th 07 11:22 AM
Using Mail Merge to import Excel data to Word for printing checks [email protected] Mailmerge 2 November 3rd 06 05:10 AM
Import data from Excel into a two column page in word jami425 Microsoft Word Help 1 March 1st 05 05:25 PM
Import Excel data into word as text Thomas1024 Microsoft Word Help 4 March 1st 05 02:22 PM
import data into word from excel or access Tlar Microsoft Word Help 0 December 12th 04 10:07 PM


All times are GMT +1. The time now is 07:34 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"