424 Error on Field to Word Doc Merge - Please Help

mardi 31 mars 2015

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

424 Error on Field to Word Doc Merge - Please Help

0 commentaires:

Enregistrer un commentaire

Labels