Forum Discussion
ShazSh
Sep 24, 2021Brass Contributor
Convert Excel Range into Word without Tables
I have created below code to copy data and paste into word the code is working fine but the problem is when it paste the data into word document then i convert the table into text. Then there are...
Juliano-Petrukio
Sep 24, 2021Bronze Contributor
Interesting .
Sub ExportToWord()
Dim WordApp As Word.Application, WordDocument As Word.Document
Set WordApp = New Word.Application
WordApp.Visible = True
Set WordDocument = WordApp.Documents.Add
ActiveSheet.UsedRange.Copy
WordDocument.Range.Paste
Application.CutCopyMode = False
Dim tbl As Object
For Each tbl In WordDocument.Tables
tbl.AutoFitBehavior wdAutoFitContent
Next
WordDocument.SaveAs Filename:=Application.ActiveWorkbook.Path & "\" & ActiveSheet.Name
Set WordDocument = Nothing
Set WordApp = Nothing
End Sub
If it helps you, remember to flag it as solved and hit the like button.
ShazSh
Sep 25, 2021Brass Contributor
No, Its not seems that i have the code in the workbook i forgot to paste. can you please check it.
- Juliano-PetrukioSep 25, 2021Bronze ContributorThe code is different from yours. I developed it from scratch based on your post. Can you please test it to see if works as you wish?
- ShazShSep 25, 2021Brass Contributor
Yes it works as mine but when i convert the Word Table to Text it removes the Excel Original tables. These are https://ibb.co/G36M177 I do not wat to remove excel original tables in wod after Converting text to table
- Juliano-PetrukioSep 25, 2021Bronze Contributor