ms-accessms-wordvbaexport-to-word

Access 2013 VBA,bad filling Word 2013 forms with data from Access 2013


I have a problem with filling Word 2013 forms with data from Access 2013. References:

Visual Basic for application MS Access 15 Office Library Ole automation MS Access 15 database engine object MS Word 15 Object Library MS ActiveX data object multi-dimensional library 2.8

My code is:

Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Set wordApp = New Word.Application
With wordApp
    .Visible = True
    Set wordDoc = .Documents.Open("C:\Template\Document.dotx", , False)
    With wordDoc
        .FormFields("NR").result = Me!NR

NR - is standard numeric format, for example 1500.00

If I type 1500.00 as a result in Document.docx I h've got 1500,00 but if i type 1500.80 (other than 00 after dot) I've got 15008,00. Printed value is ten times larger than typed.

In regional settings I have set dot separator but in Word I see coma (but in Access 2010 it worked).


Solution

  • I found an error ! Access VBA code is ok but problem was with content of Document.dotx. I wrote in my post that I have set dot separator in regional settings but in Word bookmark "NR" I saw coma. That was issue. I changed bookmark properties (number format from 0,00 to 0.00) and everythings work great. I'm sorry that I answered myself to my question but I hope this can help others to find a solution to the problem.