thisisrahul
Active Member
- Joined
- Sep 2, 2008
- Messages
- 285
I am using the below code in MS Word to copy a table from excel file to word file.
..................................
Private Sub Document_Open()
Set wdapp = GetObject(, "Word.Application")
Dim tbl As Excel.Range
Dim wordoc As Word.Document
Dim xlApp As Object
Dim xlWB As Object
Dim BookmarkArray As Variant
BookmarkArray = Array("Rahul")
Set xlApp = CreateObject("Excel.Application")
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
Set xlWB = xlApp.Workbooks.Open("\\edenaswcmfps001\IE\ADD\Rahul Mishra\Add\Bulk Deals Database.xlsm", , , , "feelgood", "feelgood")
xlApp.Visible = True
With xlWB
'.Run "SelectHD1"
.Sheets("Aggregate").Selection.Copy
End With
Selection.GoTo What:=wdGoToBookmark, _
Name:="Rahul"
wdapp.Selection.Paste
'xlApp.CutCopyMode = False
End Sub
.......................................
The above code is working fine except the pasting of table as picture. I have selected the table in excel but stuck with copying the same and paste as picture on word file.
Also suggest me to save as the word file with "User_Name 30Nov2015.doc" where date is variable.
_________
Rahul
..................................
Private Sub Document_Open()
Set wdapp = GetObject(, "Word.Application")
Dim tbl As Excel.Range
Dim wordoc As Word.Document
Dim xlApp As Object
Dim xlWB As Object
Dim BookmarkArray As Variant
BookmarkArray = Array("Rahul")
Set xlApp = CreateObject("Excel.Application")
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
Set xlWB = xlApp.Workbooks.Open("\\edenaswcmfps001\IE\ADD\Rahul Mishra\Add\Bulk Deals Database.xlsm", , , , "feelgood", "feelgood")
xlApp.Visible = True
With xlWB
'.Run "SelectHD1"
.Sheets("Aggregate").Selection.Copy
End With
Selection.GoTo What:=wdGoToBookmark, _
Name:="Rahul"
wdapp.Selection.Paste
'xlApp.CutCopyMode = False
End Sub
.......................................
The above code is working fine except the pasting of table as picture. I have selected the table in excel but stuck with copying the same and paste as picture on word file.
Also suggest me to save as the word file with "User_Name 30Nov2015.doc" where date is variable.
_________
Rahul