T
Thronz
I have an MSAccess database which calls up a Word document and populates Form
fields with data from the current record. This all works fine. My problems is
that Word is now running (I released it in VBA coding) and when I try to
close it down, I am asked if I want to saved the changes to Normal.dot. Once
I get rid of the pop-ups and close Word down, I then get messages that I
already have Normal.dot running??
Here is the code from the database:
Private Sub Printform_Click()
On Error GoTo Err_Printform_Click
Dim wrdApp As Word.Application
Dim doc As String
Dim locat As String
Dim fs
Set wrdApp = New Word.Application
Set fs = CreateObject("Scripting.FileSystemObject")
doc = "N:\Security\Reception\Forms\Contractor Renewal Form.doc"
locat = "N:\Security\Reception\Contractors" & "\" & Me.ID & ".jpg"
If fs.FileExists(locat) = False Then locat =
"N:\Security\Reception\Contractors\" & "NoPix.JPG"
wrdApp.Documents.Open filename:=doc
wrdApp.Visible = False
ActiveDocument.FormFields("Name").Result = Lastname + ", " + Me.Given1 + " "
& Me.Given2
ActiveDocument.FormFields("Address").Result = Me.Address & " " & Me.City
ActiveDocument.FormFields("ID").Result = Me.ID
ActiveDocument.FormFields("DOB").Result = Me.DOB
ActiveDocument.FormFields("Employer").Result = Me.Employer
ActiveDocument.FormFields("Reason").Result = Me.ReasonforAccess
ActiveDocument.FormFields("Contact").Result = Contact
ActiveDocument.Bookmarks("Photo").Select
Selection.InlineShapes.AddPicture filename:=locat
Options.PrintBackground = False
ActiveDocument.PrintOut
wrdApp.Documents.Close saveChanges:=wdDoNotSaveChanges
wrdApp.Quit
'Set wrdApp = Nothing
Exit Sub
Err_Printform_Click:
MsgBox ("Error")
End Sub
Thanks in advance for your time and help
fields with data from the current record. This all works fine. My problems is
that Word is now running (I released it in VBA coding) and when I try to
close it down, I am asked if I want to saved the changes to Normal.dot. Once
I get rid of the pop-ups and close Word down, I then get messages that I
already have Normal.dot running??
Here is the code from the database:
Private Sub Printform_Click()
On Error GoTo Err_Printform_Click
Dim wrdApp As Word.Application
Dim doc As String
Dim locat As String
Dim fs
Set wrdApp = New Word.Application
Set fs = CreateObject("Scripting.FileSystemObject")
doc = "N:\Security\Reception\Forms\Contractor Renewal Form.doc"
locat = "N:\Security\Reception\Contractors" & "\" & Me.ID & ".jpg"
If fs.FileExists(locat) = False Then locat =
"N:\Security\Reception\Contractors\" & "NoPix.JPG"
wrdApp.Documents.Open filename:=doc
wrdApp.Visible = False
ActiveDocument.FormFields("Name").Result = Lastname + ", " + Me.Given1 + " "
& Me.Given2
ActiveDocument.FormFields("Address").Result = Me.Address & " " & Me.City
ActiveDocument.FormFields("ID").Result = Me.ID
ActiveDocument.FormFields("DOB").Result = Me.DOB
ActiveDocument.FormFields("Employer").Result = Me.Employer
ActiveDocument.FormFields("Reason").Result = Me.ReasonforAccess
ActiveDocument.FormFields("Contact").Result = Contact
ActiveDocument.Bookmarks("Photo").Select
Selection.InlineShapes.AddPicture filename:=locat
Options.PrintBackground = False
ActiveDocument.PrintOut
wrdApp.Documents.Close saveChanges:=wdDoNotSaveChanges
wrdApp.Quit
'Set wrdApp = Nothing
Exit Sub
Err_Printform_Click:
MsgBox ("Error")
End Sub
Thanks in advance for your time and help