R
ReidarT
I have this code on a button:
Private Sub Kommando4_Click()
Dim strDokument As String
Dim Objekt As Object
Dim MyWord As Word.Application
Dim WordDoc As Word.Document
Set MyWord = CreateObject("Word.Application")
For i = 1 To 10
Set WordDoc = MyWord.Documents.Add
strDokument = "D:\test\test2\" & Me.ID & ".doc"
MyWord.Selection.Font.Name = "Arial"
MyWord.Selection.Font.Size = 14
MyWord.Selection.TypeText strDokument
WordDoc.SaveAs strDokument
Me![Objekt].SourceDoc = strDokument
Me![Objekt].Action = Ole_create_embed
WordDoc.Close
DoCmd.GoToRecord , , acNext
Set WordDoc = Nothing
Set MyWord = Nothing
Next i
End Sub
This works without the for-next, but the main problem is that an instance of
winword.exe does not close, and every time I press the button, I get one
more winword.exe in memory, and the buffer is filled.
I have to add 2000 records
regards
Reihaa
Private Sub Kommando4_Click()
Dim strDokument As String
Dim Objekt As Object
Dim MyWord As Word.Application
Dim WordDoc As Word.Document
Set MyWord = CreateObject("Word.Application")
For i = 1 To 10
Set WordDoc = MyWord.Documents.Add
strDokument = "D:\test\test2\" & Me.ID & ".doc"
MyWord.Selection.Font.Name = "Arial"
MyWord.Selection.Font.Size = 14
MyWord.Selection.TypeText strDokument
WordDoc.SaveAs strDokument
Me![Objekt].SourceDoc = strDokument
Me![Objekt].Action = Ole_create_embed
WordDoc.Close
DoCmd.GoToRecord , , acNext
Set WordDoc = Nothing
Set MyWord = Nothing
Next i
End Sub
This works without the for-next, but the main problem is that an instance of
winword.exe does not close, and every time I press the button, I get one
more winword.exe in memory, and the buffer is filled.
I have to add 2000 records
regards
Reihaa