VBA Excel Bookmarks word specific values

MB111

New Member
Joined
Sep 5, 2014
Messages
1
Hi!

In the code below, my values are getting exported to a document I created in Word. Now I would really much like them to be a specific place, so that I can get them in the middle of a sentence. I tried all kinds of bookmark-codes, but nothing seems to be working. The specific value just gets in the top of the document instead of in the text.

Can anyone help me?

Code:

Dim WordApp As Object
Set WordApp = CreateObject("word.Application")
WordApp.Visible = True

WordApp.Documents.Open "S:\BOKIS skabeloner\MB.docx"

Dim i As Integer
Dim strValue As String
For i = 5 To 5
'bring focus to the document created
WordApp.Activate
'read the value from the cell
strValue = Cells(4 + 1, 2)
'write the value to the document
WordApp.Selection.TypeText Text:=strValue
'move to the next line
WordApp.Selection.TypeParagraph

'bring focus to the document created
WordApp.Activate
'read the value from the cell
strValue = Cells(4 + 1, 3)
'write the value to the document
WordApp.Selection.TypeText Text:=strValue
'move to the next line
WordApp.Selection.TypeParagraph
'bring focus to the document created
WordApp.Activate
'read the value from the cell
strValue = Cells(4 + 1, 4)
'write the value to the document
WordApp.Selection.TypeText Text:=strValue
'move to the next line
WordApp.Selection.TypeParagraph

'bring focus to the document created
WordApp.Activate
'read the value from the cell
strValue = Cells(4 + 1, 6)
'write the value to the document
WordApp.Selection.TypeText Text:=strValue
'move to the next line
WordApp.Selection.TypeParagraph


Next i
End Sub


Regards, MB
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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