The access database was created with Access 2007. Most of my computers are running Office 2007. However, I just purchased a new computer that is running Office 2013 (home and business). I have tried Access Runtime 2007, Runtime 2013, and installed a stand alone copy of Access 2007 trying to fix this issue.
The Issue:
I have several buttons on a form that are used to populate word documents. The word documents are on a network drive. The word documents were created in Word 2007 and uses form fill boxes to receive the information. The documents are protected to allow form fill only.
Here is the code:
Code:
Private Sub printForm()
'Open up form and fill it in with information from database.
Dim appWord As Word.Application
Dim doc As Word.Document
'Avoid error 429, when Word isn't open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn't open, create a new instance of Word.
Set appWord = New Word.Application
End If
MsgBox btn
'If word isn't open, determine which instance to create
If btn = 1 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\DUIContractSignUP.docm", , True)
End If
If btn = 2 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\DefensiveDrivingSignUp.docm", , True)
End If
If btn = 3 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\CE Summary LR.docx", , True)
End If
If btn = 4 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\CE Computer Forms LR.docx", , True)
End If
If btn = 5 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\SA Assessment.docx", , True)
End If
If btn = 6 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\DV Assessment.docx", , True)
End If
If btn = 7 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\AM Assessment.docx", , True)
End If
If btn = 8 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\SL Assessment.docx", , True)
End If
If btn = 9 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\SA Contract.docx", , True)
End If
If btn = 10 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\CE Computer Forms JR.docx", , True)
End If
If btn = 11 Then
Set doc = appWord.Documents.Open("\\DUI_NAS\data\redirect\11documents\dataforms\CE Summary JR.docx", , True)
End If
MsgBox "Step 2"
With doc
.FormFields("firstName").Result = Me!pFname
.FormFields("lastName").Result = Me!pLname
.FormFields("middleName").Result = Me!pMi
.FormFields("streetAddress").Result = Me!pAddress1
.FormFields("cityAddress").Result = Me!pCity
.FormFields("stateAddress").Result = Me!pState
.FormFields("zipAddress").Result = Me!pZip
.FormFields("numberHome").Result = Me!pPhone1
.FormFields("numberCell").Result = Me!pPhone2
.FormFields("SSN").Result = Me!pSSN
.FormFields("dateBirth").Result = Me!pDOB
.FormFields("licenseNumber").Result = Me!pDLNumber
.FormFields("race").Result = Me!pRace
.FormFields("sex").Result = Me!pSex
.FormFields("DUI1").Result = Me!pDUI1
.FormFields("DUI2").Result = Me!pDUI2
.FormFields("DUI3").Result = Me!pDUI3
.FormFields("DDClassDate").Result = Me!pDDClassDate
.Visible = True
.Activate
End With
MsgBox "Step 3"
Set doc = Nothing
Set appWord = Nothing
MsgBox "Step 4"
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub
All the computers that are running Office 2007 work fine. You click the button, the word doc opens and the text boxes are populated.
On the new computer, when I click a button it acts like its going to work (i get the "O" new to the mouse pointer) but the word doc never opens.
I've added message boxes throughout the code to help with trouble shooting and I get all 4 message boxes when I click a button and the first message displays the correct btn #.
Suggestions?