clif
02-09-2012, 08:26 AM
This is the excel vba. What is the error.:banghead: Thank you very much!
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open("C:\abc.doc")
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
wrdApp.Selection.GoTo What:=wdGoToBookmark, Name:="a"
wrdApp.Selection.PasteExcelTable False, False, False
'error
Dim wkb As Excel.Workbook
Set wkb = Thisworkbook
'error
wrdApp.Selection.GoTo What:=wdGoToBookmark, Name:="b"
wrdApp.Selection.MoveRight Unit:=wdCharacter, Count:=10
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
'error
wrdApp.Selection.TypeText wkb.Worksheets("1").Cells(1, 1)
'error
Set wkb = Nothing
wrdDoc.SaveAs "D:\abc.doc"
wrdDoc.Close
wrdApp.Quit
Set wrdDoc = Nothing
Set wrdApp = Nothing
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open("C:\abc.doc")
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
wrdApp.Selection.GoTo What:=wdGoToBookmark, Name:="a"
wrdApp.Selection.PasteExcelTable False, False, False
'error
Dim wkb As Excel.Workbook
Set wkb = Thisworkbook
'error
wrdApp.Selection.GoTo What:=wdGoToBookmark, Name:="b"
wrdApp.Selection.MoveRight Unit:=wdCharacter, Count:=10
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
wrdApp.Selection.TypeBackspace
'error
wrdApp.Selection.TypeText wkb.Worksheets("1").Cells(1, 1)
'error
Set wkb = Nothing
wrdDoc.SaveAs "D:\abc.doc"
wrdDoc.Close
wrdApp.Quit
Set wrdDoc = Nothing
Set wrdApp = Nothing