Hallo an das Forum,
wie könnte man folgendes Realisieren.
Ich habe ein Word docx mit einem Textmarker und will hier nun die Nachnamen in dem Textmarker ausgeben untereinander.
Vieleicht habt Ihr da ein Tipp
Vielen Dank im Voraus
wie könnte man folgendes Realisieren.
Ich habe ein Word docx mit einem Textmarker und will hier nun die Nachnamen in dem Textmarker ausgeben untereinander.
Vieleicht habt Ihr da ein Tipp
VB.NET-Quellcode
- Imports System.Runtime.InteropServices
- Imports Microsoft.Office.Interop.Word
- Imports System.IO
- Imports System
- Imports Microsoft.Win32
- Public Class wordaendern
- Dim strFileName As String
- Private Function dok(ByVal textmarke As String, ByVal textm_value As String)
- Dim word As New Microsoft.Office.Interop.Word.Application
- Dim doc As Microsoft.Office.Interop.Word.Document
- Try
- word.Visible = (True) 'Word sehen zum Test?
- doc = word.Documents.Open("c:\tmp\123.docx")
- doc.Activate()
- If doc.Range.Bookmarks.Exists(textmarke) Then
- doc.Bookmarks().Item(textmarke).Range.Text = textm_value
- Else
- MessageBox.Show("Textmarke nicht vorhanden!")
- End If
- 'doc.SaveAs("c:\tmp\testtest.doc") 'speichere mir das Dok unter dem Namen testtest.doc
- 'doc.Close()
- ' MessageBox.Show("Datei erstellt")
- Catch ex As IOException
- MessageBox.Show("Datei nicht vorhanden.")
- Finally
- 'word.Application.Quit()
- End Try
- Return (0)
- End Function
- Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- For i As Integer = 0 To 7
- dok("Nachnamen", "franke1") ' dok( Textmarke, Inhalt)
- dok("Nachnamen", "franke2") ' dok( Textmarke, Inhalt)
- dok("Nachnamen", "franke3") ' dok( Textmarke, Inhalt)
- dok("Nachnamen", "franke4") ' dok( Textmarke, Inhalt)
- dok("Nachnamen", "franke5") ' dok( Textmarke, Inhalt)
- dok("Nachnamen", "franke6") ' dok( Textmarke, Inhalt)
- dok("Nachnamen", "franke7") ' dok( Textmarke, Inhalt)
- Next i
- End Sub
- End Class
Vielen Dank im Voraus