i found code to export table to ms word document but not work for me
this code here
Code: Select all
Sub ExportExcelTableinworddocument()
Dim wdapp As New Word.Application
On Error Resume Next
wdapp.Visible = True
wdapp.Activate
wdapp.Documents.Add
With wdapp.Selection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.BoldRun
.Font.Size = 15
.Font.ColorIndex = wdDarkRed
.TypeText "MIS Report"
End With
Sheet1.Range("A1").CurrentRegion.Copy
wdapp.Selection.Paste
Application.CutCopyMode = False
ActiveDocument.Tables(1).AllowAutoFit = True
ActiveDocument.Tables(1).AutoFitBehavior wdAutoFitContent
ActiveDocument.SaveAs2 "D:\test2\" & "ExportWord.docx"
ActiveDocument.Close
wdapp.Quit
End Sub
i want this code work too in any name sheet (active sheet) not only sheet1
i hope someone help me out..
thank in advance
susanto