pull value from excel cells into word, as text instead of table form

sakura.saki

Board Regular
Joined
Apr 12, 2012
Messages
112
Hi guys,
I am now having this problem and I searched in the internet, but didn't find what I am looking for. my job is to pull the data from an sheet into a word document. I have to import the value of some cells as normal text instead of the entire table as a form because instead of short words and numbers, some of the cells are filled with long sentences.
I have create a button on the sheet, so far I could only import the entire table into a new word, but I can´t import particular cell values into it.

so does anyone know how? maybe a piece of code, with which I could begin ?

thanks a lot!

P.S: there is something I tried to use, but didn´'t work:

Set wordapp = CreateObject("Word.Application")
'Add new Word Document
With wordapp
'.ScreenUpdating = False
.Visible = True
.Activate
End With
With wordapp.Selection


Set wordDoc = wordapp.Documents.Add
'save and close the Word document
Sheets("all teams together").Range("A2").Value.Copy
With wordDoc
.Content.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False

End With
......

the line in red is marked in yellow and there is a error message:Object required
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Here is one that I wrote a few months back. First ensure you have set your bookmarks in the Word template you are using, then use this code and modify as needed.

Code:
Private Sub GroupAT_Initialise()
'Load Group A Tantalum Traveler
Dim WdApp As Object, wd As Object, ac As Long, ws As Worksheet, wkb As Workbook
Windows("Char-Qual V1.1.xlsm").Activate
Set ws = Worksheets("Sheet2")
On Error Resume Next
Set WdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set WdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Set wd = WdApp.Documents.Open("J:\Component Engineering\Travelers_programs\Tan Cap Grp A.doc")
WdApp.Visible = True
 
 
With wd.Bookmarks
.Item("Vr").Range.InsertAfter Worksheets("Sheet2").Range("K1").Value
.Item("Vr2").Range.InsertAfter Worksheets("Sheet2").Range("K1").Value
.Item("Vr3").Range.InsertAfter Worksheets("Sheet2").Range("K1").Value
.Item("Part").Range.InsertAfter Worksheets("Sheet2").Range("A1").Value
.Item("Part2").Range.InsertAfter Worksheets("Sheet2").Range("A1").Value
.Item("Supplier").Range.InsertAfter Worksheets("Sheet2").Range("C1").Value
.Item("Date").Range.InsertAfter Worksheets("Sheet2").Range("D9").Text
.Item("Originator").Range.InsertAfter Worksheets("Sheet2").Range("E1").Value
.Item("Requester").Range.InsertAfter Worksheets("Sheet2").Range("F1").Value
End With
 
End Sub
 
Upvote 0
Hi punkid, sorry to bother you again. but now I am trying to use the code: "typeparagraph" in the document since I have to pull several cell values after a bookmark, and I would like to seperate them by the Enter key, but rather automatically. I tried the following but somehow it just doens´t work: the cell values after the book mark still stick together...do you happen to know how to do it?

Private Sub GroupAT_Initialise()
Dim i As Integer

'Load Group A Tantalum Traveler
Dim WdApp As Object, wd As Object, ac As Long, ws As Worksheet, wkb As Workbook
Windows("access tables to excel.xls").Activate
Set ws = Worksheets("all teams together")
On Error Resume Next
Set WdApp = GetObject(, "Word.Application")
If Err.number <> 0 Then
Set WdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Set wd = WdApp.Documents.Open("P:\Fraib\Doc1.doc")
WdApp.Visible = True
Set obj = WdApp.Selection
Dim wrdDoc As Word.Document
LastRow = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
For i = 2 To LastRow
If Range("A" & i).Value <> 0 Then

With wd.Bookmarks
.Item("Vr").Range.InsertAfter Worksheets("all teams together").Range("C" & i).Value

'wd.Content.InsertParagraphAfter
obj.TypeParagraph

.Item("Vr").Range.InsertAfter Worksheets("all teams together").Range("D" & i).Value
End With
'.Item("Vr2").Range.InsertAfter Worksheets("all teams together").Range("I17").Value
'.Item("Vr3").Range.InsertAfter Worksheets("all teams together").Range("C4").Value
'End With
End If
Next i
End Sub

the 2 lines in red are the code I tried, to make the same funtion as an enter key but failed...
 
Upvote 0
So if I uderstand you correctly each cell should be on its own line in Word? Bookmarks themselves can be placed anywhere within the Word document, I suppose I am just a little confused at what needs to be moved from Excel to word. Can you post the excel sheet that needs transferred?

**Also when posting code please use code tags, instructions are found here http://www.mrexcel.com/forum/misc.php?do=bbcode#code
 
Upvote 0
Hi Punkid, thanks for your reply. what you understand is perfectly right.the only problem is: there are maybe 150 rows and 7 columns...you can imagine how many book marks there would be. .. and the most terrible thing is: it is a weekly table from a user form and the value of cells changes every week due to the input. this means, some of the cells may be with or without value at all: each time it is different. and so is the length of the table itself...

I am now considering, if I should first pull everything into another sheet and makes it like a table with only one column and then into the word. it might be easier, but somehow I still get stucked...

P.S:how to upload an excel sheet by the way? I don´t see any buttons for that
 
Last edited:
Upvote 0

Forum statistics

Threads
1,225,626
Messages
6,186,089
Members
453,336
Latest member
Excelnoob223

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