Paste unformatted text and values from excel into word bookmark

womblefox

New Member
Joined
Nov 19, 2007
Messages
2
Hi,

I'm working with a complex workbook that forms a sales pricelist. This outputs to a worksheet the various components with line item & price.

I want create a macro button that copies these line items and values from Excel into a word template at a certain bookmark.

code so far is below and works fine, but it just copies the formatted excel text into the word doc. I've tried ways to paste onto the Word bookmark eg:

WrdApp.ActiveDocument.Bookmarks("Name").Range.text=Range("Name").text

but it appears to loop and then crash. I want the paste to be "Keep Text Only" option, but can't find a variable for this.

btw: i'm not a regular at VB - however I can get quite a long way by using and adapting existing code.

(this isn't for commercial use, I'm just a salesman who is sick of copy and pasting from excel into word and this will be for me only!)


Code so far:

Private Sub CommandButton4_Click()

Dim wdApp As Object
Dim wd As Object

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("C:\test\test1.docx")

wdApp.Visible = True

Worksheets("Order form English").Range("A21:P25").Copy
wd.Range.Paste


End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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