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
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...
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
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
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
danke dir ich werde es heute gleich mal ausprobieren...
Gruß Arno