W
Woahii
Hallo.
Meine Frage ist: Wie kann man einen Button in einem Formular Programmieren also welchen Code brauche ich um in einem Formular gefilterte Datensätze in ein Worddokument und auch ggf. in ein Textdokument einzulesen.
Wäre das vielleicht ein Code dafür?
Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
.Documents.Open ("C:\temp\test.doc") 'das zu öffnende Worddokument
.ActiveDocument.Bookmarks("Anrede").Select 'gehe zur Textmarke "Anrede"
.Selection.text = Me!Anrede 'schreibe in das Feld, was im Formular im Feld Anrede steht
.ActiveDocument.Bookmarks("NName").Select
.Selection.text = Me!NName
'usw...
End With
objWord.ActiveDocument.PrintOut 'ausdrucken
objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges 'nicht speichern
objWord.Quit
Set objWord = Nothing
Ich wäre für gute Tipps dankbar.
Meine Frage ist: Wie kann man einen Button in einem Formular Programmieren also welchen Code brauche ich um in einem Formular gefilterte Datensätze in ein Worddokument und auch ggf. in ein Textdokument einzulesen.
Wäre das vielleicht ein Code dafür?
Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
.Documents.Open ("C:\temp\test.doc") 'das zu öffnende Worddokument
.ActiveDocument.Bookmarks("Anrede").Select 'gehe zur Textmarke "Anrede"
.Selection.text = Me!Anrede 'schreibe in das Feld, was im Formular im Feld Anrede steht
.ActiveDocument.Bookmarks("NName").Select
.Selection.text = Me!NName
'usw...
End With
objWord.ActiveDocument.PrintOut 'ausdrucken
objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges 'nicht speichern
objWord.Quit
Set objWord = Nothing
Ich wäre für gute Tipps dankbar.