Microsoft Office Forums Export data to word table

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2019, 10:31 AM
Dzib Dzib is offline Export data to word table Windows 10 Export data to word table Office 2019
Novice
Export data to word table
 
Join Date: Jul 2019
Posts: 29
Dzib is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 08-27-2019, 01:45 PM
Kenneth Hobson Kenneth Hobson is offline Export data to word table Windows 10 Export data to word table Office 2016
Advanced Beginner
 
Join Date: Jun 2018
Posts: 37
Kenneth Hobson is on a distinguished road
Default

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")
Reply With Quote
  #3  
Old 08-27-2019, 02:16 PM
Dzib Dzib is offline Export data to word table Windows 10 Export data to word table Office 2019
Novice
Export data to word table
 
Join Date: Jul 2019
Posts: 29
Dzib is on a distinguished road
Default

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
Works perfect with


Code:
wd.Tables(2).Cell(2, 3).Range = Range("A1")

Thanks mate
Reply With Quote
  #4  
Old 08-27-2019, 11:30 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Export data to word table Windows 7 64bit Export data to word table Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,397
Pecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of light
Default

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.
__________________
Please note I am not active on this forum anymore
Reply With Quote
  #5  
Old 08-28-2019, 01:09 AM
Dzib Dzib is offline Export data to word table Windows 10 Export data to word table Office 2019
Novice
Export data to word table
 
Join Date: Jul 2019
Posts: 29
Dzib is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 08-28-2019, 06:26 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Export data to word table Windows 7 64bit Export data to word table Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,397
Pecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of light
Default

Please add the link as requested. Thanks
__________________
Please note I am not active on this forum anymore
Reply With Quote
  #7  
Old 08-28-2019, 06:33 AM
Dzib Dzib is offline Export data to word table Windows 10 Export data to word table Office 2019
Novice
Export data to word table
 
Join Date: Jul 2019
Posts: 29
Dzib is on a distinguished road
Default

Link to thread on Mr Excel forum: Copy / Paste from Excel to Word
Reply With Quote
  #8  
Old 08-28-2019, 11:51 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Export data to word table Windows 7 64bit Export data to word table Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,397
Pecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of light
Default

Thanks a lot
__________________
Please note I am not active on this forum anymore
Reply With Quote
Reply

Thread Tools
Display Modes


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
Export data to word table VBA Export Data as Text from Excel to Word lwbarnes Word VBA 3 06-09-2016 02:47 PM
Export data to word table Export Word Form Data to Access pboland Word VBA 1 06-12-2015 06:53 PM
Export data to word table 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


All times are GMT -7. The time now is 10:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft