The "wrap text" option works in Excel but once pasted in Word the cell disappear as you can see on these pictures:
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:=1
With .Find
.ClearFormatting
.Text = vbTab
.Replacement.ClearFormatting
.Replacement.Text = " "
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
End With
End With
End Sub
I could put a blank character in column C and that works but I thought maybe there's a more "clean" solution...