424 Error on Field to Word Doc Merge - Please Help

rkoch

New member
Local time
Today, 21:18
Joined
Mar 31, 2015
Messages
4
Hi,
Can anyone please point me in the right direction with the following code.
i am trying to take an Access 2010 Field values and merge into a formated Word 2010 document.
Error 424 occurs at the Red Highlighted Line.
Many Thanks in Advance.
Ron


Dim oApp As Object

'Path to the word document
LWordDoc = "C:\Cliik_Access_Database\Document Templates\PolicyCliik092014x.docx"

If Dir(LWordDoc) = "" Then
MsgBox "The Required Policy Document was not found, Please see IT Department to ensure document name and location are correct. In the event of a recent Policy Update these details may need amending within the database to reflect the new revision number. The current REVISION NUMBER IS 09/2014."

Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True

'Open the Document
oApp.Documents.Open FileName:=LWordDoc
End If
With doc
.FormFields("fldprem1").Result = Me!PREM1
.FormFields("fldprem2").Result = Me!PREM2
.FormFields("fldprem3").Result = Me!PREM3
.FormFields("fldprem4").Result = Me!PREM4
.FormFields("fldprem5").Result = Me!PREM5
.FormFields("fldprem6").Result = Me!PREM6
.FormFields("fldprem7").Result = Me!PREM7
.FormFields("fldprem8").Result = Me!PREM8
.FormFields("fldprem9").Result = Me!PREM9
.FormFields("fldprem10").Result = Me!PREM10
.FormFields("fldprem11").Result = Me!PREM11
.FormFields("fldprem12").Result = Me!PREM12
.FormFields("fldprem13").Result = Me!PREM13
.FormFields("fldprem14").Result = Me!PREM14
.FormFields("fldprem15").Result = Me!PREM15
.FormFields("fldprem16").Result = Me!PREM16
.FormFields("fldprem17").Result = Me!PREM17
.FormFields("fldprem18").Result = Me!PREM18
.FormFields("fldprem19").Result = Me!PREM19
.FormFields("fldprem20").Result = Me!PREM20
.FormFields("fldprem50").Result = Me!PREM50
.FormFields("fldprem52").Result = Me!PREM52
.FormFields("fldprem60").Result = Me!PREM60
.FormFields("fldprem100").Result = Me!PREM100
.FormFields("fldendorsements").Result = Me!Endorsements
.FormFields("fldinsurancepremiumtax").Result = Me!IPTotal
.FormFields("fldgrandtotal").Result = Me!GRANDTOTAL


.Visible = True
.Active
End With
Set doc = Nothing
Set appWord = Nothing



End Sub
 
If anyone could point me in the right direction with the above I would be most grateful. I am working to a time frame and time is running out. Any help would be appreciated. Many thanks in advance.
 
What is error 424? We do not have them tatooed on the inside of our eyelids :)
 
Sorry Error as follows;
"Run-time Error '424': Object Required"
Many thanks for any help you can offer.
 
doc is not defined : that's what the error says and that is what is absent from your code
 
Many thanks for that.
I have struggled to get this far (basic vb knowledge only).
Could you show me how to define it please??
The code is inserted into the VB properties in an Access 2010 database.
Again Many thanks
 
I'm not much into word - wait for someone to make sense of this. Or check up same place from where you copied the code - there is a bit missing.
 

Users who are viewing this thread

Back
Top Bottom