Jump to content

aus datagrid lesen


Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Recommended Posts

Hi Phoenix,

 

das ist schon ein bisschen allgemein, ohne Code ist es recht schwierig das zu beantworten ... aber im Prinzip läuft es so:

 

Du initialisierst dir ein Word.Application-Objekt und ein zugehöriges Word.Document-Objekt und überträgst die Daten vom DataGrid in eine (neue) Tabelle im Word.Document (je nach dem, ob die Datei neu erzeugt wird oder bereits besteht bzw. evtl. die Tabelle schon vorhanden ist, oder dynamisch erstellt werden muss).

 

Grüße

Link to comment

Das ist im Prinzip nicht sehr schwer:

 With Word.Application
.Selection.TypeText(Text:="Nr")
.Selection.MoveRight(Unit:=WdUnits.wdCell)
.Selection.Font.Bold = True
.Selection.Font.Size = 14
.Selection.Font.Color = WdColor.wdColorBlue
.Selection.TypeText(Text:="Nachname")
.Selection.MoveRight(Unit:=WdUnits.wdCell)
.Selection.Font.Bold = True
.Selection.Font.Size = 14
.Selection.Font.Color = WdColor.wdColorBlue
.Selection.TypeText(Text:="Vorname")
'usw.

Link to comment

so sieht der quellcode aus

Dim oTable As Word.Table

Dim oWord As Word.Application

oWord = New Word.Application

Dim oDoc As Word.Document

Dim wdUnits As Word.WdUnits

 

oWord.Visible = True

oDoc = oWord.Documents.Add(Template:="C:\dok2.doc", NewTemplate:=False)

oDoc.FormFields.Item("Name").Range.Text = txtName.Text

oDoc.FormFields.Item("PLZ").Range.Text = txtPLZ.Text

oDoc.FormFields.Item("Ort").Range.Text = txtOrt.Text

 

'With Word.Application

oWord.Selection.TypeText(Text:="Nr")

oWord.Selection.MoveRight(Unit:=wdUnits.wdCell)

oWord.Selection.Font.Bold = True

oWord.Selection.Font.Size = 14

oWord.Selection.TypeText(Text:="Nachname")

oWord.Selection.MoveRight(Unit:=WdUnits.wdCell)

oWord.Selection.Font.Bold = True

oWord.Selection.Font.Size = 14

oWord.Selection.TypeText(Text:="Vorname")

Link to comment

Im Prinzip machst das so:

Dim oWord As Word.Application

oWord = New Word.Application

With oWord 
 .Visible = True
 .Documents.Add(DocumentType:=WdNewDocumentType.wdNewBlankDocument)
 .ActiveDocument.Tables.Add(Range:=.Selection.Range, NumRows:= DataGrid1.VisibleRows, NumColumns:= DataGrid1.VisibleCols)
 .Selection.TypeText(Text:=DataGrid1.Columns("ErsterSpaltenName"))
 .Selection.MoveRight(Unit:=WdUnits.wdCell)
 .Selection.TypeText(Text:="DataGrid1.Columns("ZweiterSpaltenName"))
'usw. bis du den kompletten Kopf befüllt hast --> mit MoveRight immer zur nächsten Zelle springen
'danach gehst du weiter Zeile für Zeile durch das DataGrid und überträgst die Daten
End With

Link to comment
Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...