sashapixie
Board Regular
- Joined
- Aug 29, 2013
- Messages
- 71
- Office Version
- 365
- Platform
- Windows
Hello There,
I have the following vba written in my access 2013 database:
Private Sub CmbMobileReceipt_Click()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim sEmployeeFullName As String
sEmployeeFullName = Full_Name
sMobileNumber = Mobile_Phone
'Open Word
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
'Print Employee handbook receipts
MobileReceipt = CurrentProject.Path & "\Mobile Phone acceptance letter"
Set wrdDoc = wrdApp.Documents.Open(MobileReceipt)
With wrdApp.ActiveDocument.Bookmarks
.Item("EmployeeFullName").Range.Text = sEmployeeFullName
.Item("MobileNumber").Range.Text = sMobileNumber
wrdApp.ActiveDocument.PrintOut
wrdApp.ActiveDocument.Close
'Close Word
wrdApp.Application.Quit
'Clean up code
Set wrdApp = Nothing
End With
End Sub
When I run this code a file appears in my folder location with the same document name but the file type is a file and not a word document, when I run the code again it always opens this file, does anyone know why this is happening or how I can delete the file?
I have the following vba written in my access 2013 database:
Private Sub CmbMobileReceipt_Click()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim sEmployeeFullName As String
sEmployeeFullName = Full_Name
sMobileNumber = Mobile_Phone
'Open Word
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
'Print Employee handbook receipts
MobileReceipt = CurrentProject.Path & "\Mobile Phone acceptance letter"
Set wrdDoc = wrdApp.Documents.Open(MobileReceipt)
With wrdApp.ActiveDocument.Bookmarks
.Item("EmployeeFullName").Range.Text = sEmployeeFullName
.Item("MobileNumber").Range.Text = sMobileNumber
wrdApp.ActiveDocument.PrintOut
wrdApp.ActiveDocument.Close
'Close Word
wrdApp.Application.Quit
'Clean up code
Set wrdApp = Nothing
End With
End Sub
When I run this code a file appears in my folder location with the same document name but the file type is a file and not a word document, when I run the code again it always opens this file, does anyone know why this is happening or how I can delete the file?