#1
|
|||
|
|||
Export data to word table
Hi,
Is it possible to extract data from a cell in excel and paste it in, for example, the second table of a word template row 2, cell 3? I've only managed to paste at the end of the word doc... Thanks |
#2
|
|||
|
|||
If you post code, it is easier to help. If you have the document object set, then use that instead of ActiveDocument. e.g.
Code:
ActiveDocument.Tables(2).Cell(2, 3).Range = Range("A1") |
#3
|
|||
|
|||
Thanks Kenneth, here's my code:
Code:
Sub ExportInvNL() Dim wdApp As Object Dim wd As Object Dim xlSheet As Worksheet Dim rng As Range Dim LastRow As Long Const wdReplaceAll As Long = 2 Const wdFindContinue As Long = 1 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.Add("C:\Users\laure\Documents\Boulot\TestInventarisNL.docx") wdApp.Visible = True Set xlSheet = ActiveWorkbook.Sheets("INV") With xlSheet LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row Set rng = .Range("A2:C" & LastRow) rng.Copy With wd.Range .Collapse Direction:=0 .InsertParagraphAfter .PasteSpecial DataType:=3 With .Find .ClearFormatting .Text = vbTab .Replacement.ClearFormatting .Replacement.Text = " " .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue End With End With End With End Sub Code:
wd.Tables(2).Cell(2, 3).Range = Range("A1") Thanks mate |
#4
|
||||
|
||||
Hi and welcome
Please,do not crosspost your question on multiple forums without including links here to the other threads on other forums. Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post. Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site). If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question Do not post any further responses in this thread until a link has been provided to these cross posts.
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#5
|
|||
|
|||
Ho well, sorry, last thing I want is waste people's time, I juste wanted to increased my chances of getting an answer...
Anyway, problem solved, thanks |
#6
|
||||
|
||||
Please add the link as requested. Thanks
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#7
|
|||
|
|||
Link to thread on Mr Excel forum: Copy / Paste from Excel to Word
|
#8
|
||||
|
||||
Thanks a lot
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to export a table to Word | Dzib | Excel Programming | 2 | 07-28-2019 02:36 AM |
VBA Export Data as Text from Excel to Word | lwbarnes | Word VBA | 3 | 06-09-2016 02:47 PM |
Export Word Form Data to Access | pboland | Word VBA | 1 | 06-12-2015 06:53 PM |
Export data from C# winForms treeView to MS-Word MergeFields | nisim651 | Mail Merge | 8 | 04-18-2014 04:17 AM |
Microsoft word table export ? -need help- | --alexander-- | Word | 2 | 04-17-2013 11:13 PM |