Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Zelleninhalt per VBA - Makro nach Word kopieren

1,457 views
Skip to first unread message

Arno Lesmeister

unread,
Jun 12, 2002, 11:25:13 AM6/12/02
to
Hallo NG

ich versuche den Zelleninhalt von Excel nach Word zu kopieren aber irgendwie
gelingt es mir nicht.

Das öffnen von Word ist kein Problem und das entsprechende Dokument anzeigen
zu lassen aber die Daten aus Excel in das Dokument und an die richtige
Stelle zu plazieren schon.

Wenn jemand eine Lösung für mich hat in Form eines Beispieles oder Codes
wäre ich echt dankbar ihr könnt die Beispiele auch gerne zu meiner Mail -
Adresse senden..

Ich danke alle im voraus für eure Hilfe

Ich benutze Word + Excel 97 im NT 4.0 Umfeld...

MFG Arno Lesmeister


Bernd Held

unread,
Jun 12, 2002, 12:22:14 PM6/12/02
to
Hallo Arno,

versuchs mal hiermit:

Sub KopierenZellenNachWord()
Dim objWord As Word.Application
Dim objDoc As Word.Document
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Add

With Sheets("Tabelle1")
Range("A1").Select
End With

objWord.Visible = True
Selection.Copy
With objWord
.Selection.Paste
.PrintOut
End With
Application.CutCopyMode = False
Set objWord = Nothing
Set objDoc = Nothing
End Sub

Viele Grüße
Bernd
MVP für Microsoft Excel
Excel-Know-How unter http://held-office.de

"Arno Lesmeister" <Arno.Le...@t-online.de> schrieb im Newsbeitrag
news:ae7pfd$5e2$04$1...@news.t-online.com...

Michael Zimmermann

unread,
Jun 12, 2002, 4:19:26 PM6/12/02
to
Hallo, Bernd!

Bernd Held <held-...@t-online.de> schrieb:

> Hallo Arno,
>
> versuchs mal hiermit:
>
> Sub KopierenZellenNachWord()
> Dim objWord As Word.Application
> Dim objDoc As Word.Document
> Set objWord = New Word.Application
> Set objDoc = objWord.Documents.Add
>
> With Sheets("Tabelle1")
> Range("A1").Select
> End With
>
> objWord.Visible = True
> Selection.Copy
> With objWord
> .Selection.Paste
> .PrintOut
> End With
> Application.CutCopyMode = False
> Set objWord = Nothing
> Set objDoc = Nothing
> End Sub

Warum so umständlich mit Selection und Copy-Paste?

> Sub KopierenZellenNachWord()
> Dim objWord As Word.Application

Dim Transportvariable as Variant

> Set objWord = New Word.Application
> Set objDoc = objWord.Documents.Add
>

Transportvariable =
Sheets("Tabelle1").Range("A1").Value
>
> objWord.Visible = True

objWord.ActiveDocument.Range.Text = Transportvariable

> Set objWord = Nothing
> Set objDoc = Nothing
> End Sub

Und den Verweis in Excel auf die Word-Bibliothek
nicht vergessen - sonst gibt's Mecker von Excel
wegen Word.Application etc.

Gruß
Michael

Arno Lesmeister

unread,
Jun 13, 2002, 12:44:53 PM6/13/02
to
Hallo Bernd, Michael,

danke für eure Hilfe genau das war es was ich eigentlich auch suchte.
Allerdings besteht noch ein Problemchen meinersteite das ihr gewiss auch
schnell raus habt.

Wie kann ich denn den Zelleninhalt in Textfelder kopieren ??


Danke für euere Hilfe...

Gruß Arno


Michael Zimmermann

unread,
Jun 13, 2002, 2:55:14 PM6/13/02
to
Hallo, Arno!
Arno Lesmeister <Arno.Le...@t-online.de> schrieb:

> Hallo Bernd, Michael,
>
> danke für eure Hilfe genau das war es was ich eigentlich
auch suchte.
> Allerdings besteht noch ein Problemchen meinersteite das
ihr gewiss auch
> schnell raus habt.
>
> Wie kann ich denn den Zelleninhalt in Textfelder kopieren
??

Zur Erinnerung:


> > Sub KopierenZellenNachWord()
> > Dim objWord As Word.Application
>
> Dim Transportvariable as Variant
>
> > Set objWord = New Word.Application
> > Set objDoc = objWord.Documents.Add
> >
> Transportvariable =
> Sheets("Tabelle1").Range("A1").Value
> >
> > objWord.Visible = True
>

Ab hier ändert sich etwas!

> objWord.ActiveDocument.Range.Text =
Transportvariable
>
> > Set objWord = Nothing
> > Set objDoc = Nothing
> > End Sub


Probier diesen hier erstmal in einem leeren
Word-Dokument, in dem Du zuerst ein Textfeld
zeichnest, um ein Gefühl dafür zu kriegen:

Dim x As Shape
Set x = ActiveDocument.Shapes(1)
x.TextFrame.TextRange.Text = "Hallo"

Von Excel aus beachten:

x as Word.Shape

Shapes(1) ist das erste Autoform-Element. (Auch
andere als Textboxen, z. B. Kreise oder sonstiges
Zeugs.)
Die 1 mußt Du ändern, je nachdem, welche Nummer
Deine Textbox hat.

Set x = ActiveDocument.Shapes(1)
x.TextFrame.TextRange.Text = Transportvariable

Gruß
Michael

--
Diese Woche im Angebot: Original ukrainischer Blowfish mit
expliciter Variablendeklaration, nahezu sprungmarkenfrei,
100 Zeilen nur 1,99

Arno Lesmeister

unread,
Jun 14, 2002, 12:50:13 AM6/14/02
to
Guten morgen Michael,

danke dir ich werde es heute gleich mal ausprobieren...

Gruß Arno


0 new messages