Copy/Paste word using VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-2065001%22%20slang%3D%22de-DE%22%3ECopy%2FPaste%20word%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2065001%22%20slang%3D%22de-DE%22%3E%3CP%3EHi%20guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20try%20to%20copy%2Fcut%20a%20word%20in%20a%20table%20cell%20but%20it%20does%20not%20work%20and%20the%20cell%20is%20empty%20after%20the%20code%20runned.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3EPublic%20Sub%20Tabelle_Einfuegen()%0A%20%20%20%20%0A%20%20%20%20Dim%20word%20As%20String%0A%20%20%20%20Dim%20i%20As%20Integer%0A%20%20%20%20%0A%20%20%20%20i%20%3D%201%0A%20%20%20%20%0A%20%20%20%20Set%20BeginnDokument%20%3D%20ActiveDocument.Range(0%2C%200)%0A%20%20%20%20%0A%20%20%20%20ActiveDocument.Tables.Add%20Range%3A%3DBeginnDokument%2C%20NumRows%3A%3D1%2C%20NumColumns%3A%3D1%0A%20%20%20%20ActiveDocument.Words(1).Copy%0A%20%20%20%20ActiveDocument.Tables(1).Cell(1%2C%201).Range.Paste%0A%20%20%20%20i%20%3D%20i%20%2B%201%0A%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20this%20code%20actually%20do%20what%20I%20want%2C%20isn't%20it%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThx!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2065001%22%20slang%3D%22de-DE%22%3E%3CLINGO-LABEL%3EWord%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

Hi guys,

 

I try to copy/cut a word in a table cell but it does not work and the cell is empty after the code runned.

 

Public Sub Tabelle_Einfuegen()
    
    Dim word As String
    Dim i As Integer
    
    i = 1
    
    Set BeginnDokument = ActiveDocument.Range(0, 0)
    
    ActiveDocument.Tables.Add Range:=BeginnDokument, NumRows:=1, NumColumns:=1
    ActiveDocument.Words(1).Copy
    ActiveDocument.Tables(1).Cell(1, 1).Range.Paste
    i = i + 1

End Sub

 

But this code actually do what I want, isn't it?

 

Thx!

0 Replies