Ich brauche einen Vb-Code in MS Word 2003, die eine bestimmte Zelle in Excel-Datei kopieren und in Word (Feld) einfügen. Unten ist was ich getan habe und es führt zu einem Fehler.Wie kopiere ich Wert aus einer Zelle in MSExcel in ein Feld in MSWord-Datei mit VB-Code?
Sub cmdGetNumber()
Dim XL As Object
Dim WBEx As Object
Dim ExelWS As Object
Dim appwd As Object
Dim wdApp As Word.Application
''''
'On Error GoTo OLE_ERROR
Set XL = CreateObject("Excel.Application")
Set wdApp = CreateObject("Word.Application")
'Open Excel document
Set WBEx = XL.Workbooks.Open("C:\Documents and Settings\121567\Desktop\tafket1.xls")
Set ExelWS = WBEx.Worksheets("Sheet1")
XL.Visible = True
'appwd.Visible = True
ExelWS.Range("c2").Select
'Selection.Copy
'wdApp.Selection.PasteSpecial Placement:=wdInLine, DataType:=wdPasteMetafilePicture
'wdApp.Documents.Save
Set wdApp = Nothing
Set ExelWS = Nothing
Set WBEx = Nothing
End Sub
Vielleicht versuchen wdPasteText oder wdPasteRTF anstelle von wdPasteMetafilePicture? – barrowc
Bitte fügen Sie den Fehlertext am Ende Ihrer Frage ein. – RBarryYoung