ChrisCione
Board Regular
- Joined
- Aug 27, 2008
- Messages
- 92
- Office Version
- 365
- Platform
- Windows
My MDB contains the following code to allow me to export data into a Word fillable form. I've used it for years. Just a few days ago, it quit working. What I mean is that when I click the command button this code is attached to, nothing happens. At all. No error, just nothing.
I use this at work. The only changes I'm aware of is continuous weekly "pushes" of any software updates by our IT department. The version of office I have on my machine is Professional Plus 2010. The IT folks tell me that last major update was sometime ago. But something's obviously changed that killed this code. I didn't change the Word doc at all, or the path. Any ideas?
<code>
'Download to SF39 Word Template.
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
Set doc = appWord.Documents.Open("O:\CIONE\~Recruitments\Recruitment Database\Forms\SF39_WORD.docm", , True)
With doc
.FormFields("Class").Result = Me!Class
.FormFields("VIN").Result = Me!VIN
.FormFields("VAOpen").Result = Me!VAOpen
.FormFields("VAClose").Result = Me!VAClose
.FormFields("PaySystem").Result = Me!PaySystem
.FormFields("Series").Result = Me!Series
.FormFields("Grades").Result = Me!Grades
.FormFields("SF52Number").Result = Me!SF52Number
.FormFields("SM1").Result = Me!SM1
.FormFields("SM2").Result = Me!SM2
.FormFields("AnnounceType").Result = Me!AnnounceType
.FormFields("AnnounceType").Result = Me!AnnounceType
.FormFields("PlannedHires").Result = Me!PlannedHires
.FormFields("RequestDate").Result = Me!RequestDate
.FormFields("CertNumber1").Result = Me!CertNumber1
.FormFields("CertNumber2").Result = Me!CertNumber2
.FormFields("CertNumber3").Result = Me!CertNumber3
.FormFields("CertIssued").Result = Me!CertIssued
.FormFields("CertDue").Result = Me!CertDue
.FormFields("DutyLocation1").Result = Me!DutyLocation1
.FormFields("DutyLocation2").Result = Me!DutyLocation2
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
</code>
I use this at work. The only changes I'm aware of is continuous weekly "pushes" of any software updates by our IT department. The version of office I have on my machine is Professional Plus 2010. The IT folks tell me that last major update was sometime ago. But something's obviously changed that killed this code. I didn't change the Word doc at all, or the path. Any ideas?
<code>
'Download to SF39 Word Template.
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
Set doc = appWord.Documents.Open("O:\CIONE\~Recruitments\Recruitment Database\Forms\SF39_WORD.docm", , True)
With doc
.FormFields("Class").Result = Me!Class
.FormFields("VIN").Result = Me!VIN
.FormFields("VAOpen").Result = Me!VAOpen
.FormFields("VAClose").Result = Me!VAClose
.FormFields("PaySystem").Result = Me!PaySystem
.FormFields("Series").Result = Me!Series
.FormFields("Grades").Result = Me!Grades
.FormFields("SF52Number").Result = Me!SF52Number
.FormFields("SM1").Result = Me!SM1
.FormFields("SM2").Result = Me!SM2
.FormFields("AnnounceType").Result = Me!AnnounceType
.FormFields("AnnounceType").Result = Me!AnnounceType
.FormFields("PlannedHires").Result = Me!PlannedHires
.FormFields("RequestDate").Result = Me!RequestDate
.FormFields("CertNumber1").Result = Me!CertNumber1
.FormFields("CertNumber2").Result = Me!CertNumber2
.FormFields("CertNumber3").Result = Me!CertNumber3
.FormFields("CertIssued").Result = Me!CertIssued
.FormFields("CertDue").Result = Me!CertDue
.FormFields("DutyLocation1").Result = Me!DutyLocation1
.FormFields("DutyLocation2").Result = Me!DutyLocation2
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
</code>