Je dois avoir un code vb dans MS Word 2003 qui copient une cellule spécifique dans un fichier Excel et le collez dans un mot (déposé). Voici ce que j'ai fait et il en résulte une erreur.Comment copier la valeur d'une cellule dans MSExcel dans un champ dans un fichier MSWord avec le code VB?
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
Peut-être essayer wdPasteText ou wdPasteRTF au lieu de wdPasteMetafilePicture? – barrowc
Veuillez coller le texte d'erreur à la fin de votre question. – RBarryYoung