Inserting from Excel into Word document using VBA not as image?

tims31

New Member
Joined
Jul 3, 2014
Messages
38
Hi,

I have been trying to take data from excel and insert into a word document using VBA and have used the code in this thread VBA Export excel data

I have removed the save element as want to insert the data and then be able to edit elements of the rest of the document and then save as a different file name.

Two issues I have is, it inserts as an image and Inserts at the very top of the word document.

So, is it possible to insert as Paste Special> Values & Source formatting rather than as a picture and/or insert at a point in the document why you can specify. In the top line I have a line of text and wish to have the Excel data pasted below the this line of text. I tried to have it select the end of the line and do a return but just kept getting errors.
If I can do either then it will solve the issue as I can either add the line of text to the top of the excel data (but still be able to edit it) or insert the excel data after the line of text? I have added an image so you can see what I mean.

VBA Code:
Sub DailyReportData()

Dim WdObj As Object, fname As String
fname = "Daily Report Output"
Set WdObj = CreateObject("Word.Application")
WdObj.Visible = False
Range("A1:E33").Select
Selection.Copy 'Your Copy Range
WdObj.Documents.Open Filename:="C:\Users\PATHtoFile\Daily Report DATE.docx"
WdObj.Selection.PasteSpecial Link:=False, _
DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
Application.CutCopyMode = False


End Sub

Any help will be gratefully received, VBA is not my strong point I'm affraid.
 

Attachments

  • Report-xampl.png
    Report-xampl.png
    8.5 KB · Views: 20

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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