Values From Excel To Word

Chris Williamson

Board Regular
Joined
Oct 16, 2010
Messages
83
Hi guys, is it possible to take information from cells in an excel worksheet and put those values in a word document at a click of a button?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
This little macro code shown below opens up a word template as a document, the document itself is a simple form… there are several ‘Text Form Field’ boxes in the word template so when the file is in the protected mode - you just need to press the TAB key to move to the next field.
<o:p></o:p>
The properties for these ‘Text Form Field’ boxes have ‘Bookmarks’ associated with them, for example ‘Text1’.
<o:p></o:p>
How do you take the value from cell ‘A1’ in excel and put that value in the bookmark name ‘Text1’ in this new word document when you click a button?<o:p></o:p>

<o:p></o:p>
Sub Excel_To_Word_Test()<o:p></o:p>
<o:p></o:p>
Code:
If [Check Box 1].Value = 1 Then<o:p></o:p>
Dim objWord As Object<o:p></o:p>
Set objWord = CreateObject("Word.Application")<o:p></o:p>
objWord.Visible = True<o:p></o:p>
objWord.Documents.Add "\**File Location**\Word.dot"<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
End Sub
<o:p></o:p>
<o:p></o:p>
Thank you.
<o:p></o:p>
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You would need to use the goto bookmark command

Range("A1").Copy
With wrdApp
.Documents.Open "Path to Doc.doc" 'Place in full path and Document name including .doc
.Selection.GoTo What:=wdGoToBookmark, Name:="test1" 'Using a bookmark in the document
.Selection.PasteAndFormat (wdPasteDefault)
.Visible = True
.Documents.Save
End With

 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top