I have an Access 2010 application which in places interfaces with MS Word, to both create docs and read from them.



The VBA procedure to create docs does this:

- open an MS Word file to use as a template (it's not an actual Word template file)
- fill in various existing locations using bookmarks
- add a variable number of rows to the MS Word table
- save the edited file to a known location with a VBA determined file name

Here is an edited version of the code, leaving out parts that I know are not an issue:

Code:
Sub Export_Competency(Competency_Code As String, Competency_Instance As Integer, wrdApp As Word.Application)
  Dim CurrentProcedure As String
  Dim db As Database, rst As Recordset
  Dim SQL As String
  Dim InstanceWhere As String
  Dim TranslationNumber As Long
  Dim ExportFileName As String
  Dim TemplateFileName As String
  Dim ItemCount As Integer
  Dim CompetencyType As Integer
  Dim wrdDoc As Word.Document
  Dim Item_ID As String
  Dim File_Prefix As String
  CurrentProcedure = "Export_Competency"
  On Error GoTo Proc_Error
  '
  ' Determine the competency type
  ' Competency type 2, National Qualification, has few items associated with it
  '
  CompetencyType = DLookup("CmptcyCat_CDE", "Competency", "Cmptcy_Code_ID = '" & Competency_Code & "'")
'  If CompetencyType = 1 Then File_Prefix = "SS"
'  If CompetencyType = 2 Then File_Prefix = "QL"
'  If CompetencyType = 3 Then File_Prefix = "RQ"
'  If CompetencyType = 4 Then File_Prefix = "EQ"
'  If CompetencyType = 5 Then File_Prefix = "PG"
  File_Prefix = Nz(Choose(CompetencyType, "SS", "QL", "RQ", "EQ", "PG"), "UK")
  '
  ' Generate Template and output file names
  '
  TemplateFileName = DLookup("DocumentTemplates", "Control")
  TemplateFileName = TemplateFileName & "\" & "OSS_Translation_Request_Template.doc"
  
  ExportFileName = DLookup("ExportTranslationPath", "Control")
  ExportFileName = ExportFileName & "\" & File_Prefix & "_Translation_" & Competency_Code & "_" & Format(Date, "dd-MMM-yyyy")
  '
  ' open the template file
  '
  Set wrdDoc = wrdApp.Documents.Open(TemplateFileName, , , , , , , , , , , False)
  MsgBox "Document name is " & wrdDoc.Name
  Set db = CurrentDb
  InstanceWhere = "[cmptcyinst_ID] = " & Competency_Instance
  '
  ' Code snipped
  '
  '
  ' Description
  '
  Set rst = db.OpenRecordset("Translate competency description")

  wrdDoc.Bookmarks("OSS_code").Range.InsertAfter Competency_Code
  wrdDoc.Bookmarks("OSS_name").Range.InsertAfter rst!Cmptcy_Name_En
  wrdDoc.Bookmarks("file_date").Range.InsertAfter Format(Date, "dd-MMM-YYYY")
  wrdDoc.Bookmarks("file_name").Range.InsertAfter ExportFileName
  wrdDoc.Bookmarks("Instance_ID").Range.InsertAfter Competency_Instance
  wrdDoc.Bookmarks("Instance_Type").Range.InsertAfter " 2 (Competency)"
  wrdDoc.Bookmarks("Full_Listing").Range.InsertAfter "No"
  wrdDoc.Bookmarks("Status_Code").Range.InsertAfter "5"
  wrdDoc.Bookmarks("Status_Text").Range.InsertAfter "Approved"
  ItemCount = 0
  
  If rst!Cmptcy_Name_Lang_IND = 1 Then
    '
    ' Competency name
    '
    TranslationNumber = Add_Translation_Record("Competency_Description", "cmptcydsc_ID", rst!CmptcyDsc_ID, "cmptcy_Name_fr", _
      rst!Cmptcy_Name_En, Nz(rst!Cmptcy_Name_Fr, "N/A"), 0, Competency_Instance, "Cmptcy_Name_Lang_IND")
    Item_ID = "Name"
    MsgBox "Writing " & Item_ID & " to " & wrdDoc.Name
    Write_Item wrdApp, wrdDoc, ItemCount, TranslationNumber, rst!Cmptcy_Name_En, _
       IIf(ExportFrench, Nz(rst!Cmptcy_Name_Fr, " "), " "), Item_ID
    '
    ' Competency Abbreviation
    '
    '
    '  Lots more code snipped
    '
The procedure Write_Item updates the first row in the table (it's already in the template) and then adds rows to the MS Word table as required. Here is it's code (also edited):

Code:
Public Sub Write_Item(wrdApp As Word.Application, wrdDoc As Word.Document, ItemCount As Integer, TranslationItem As Long, _
      English As String, ExistingFrench As String, Optional Item_ID As String = "?")
  Dim CurrentProcedure As String
  Dim wrdRange As Word.Range
  Dim Currentrow As Integer
'  On Error GoTo Proc_Error
  CurrentProcedure = "Write_Item"
  ItemCount = ItemCount + 1
   
  If ItemCount = 1 Then
    MsgBox "Write_Item received '" & English & "' to to to the bookmark 'Name' in " & wrdDoc.Name
    '
    ' Go to the item bookmark, and update that row
    '
    Set wrdRange = wrdDoc.GoTo(What:=wdGoToBookmark, Name:="Item")
    wrdRange.Select
    wrdRange.InsertAfter TranslationItem
    '
    ' Move to the next cell to the right, for English
    '
    wrdApp.Selection.Move wdCell, 1
    wrdApp.Selection.InsertAfter English
    '
    ' Move to the next cell to the right, for French
    '
    wrdApp.Selection.Move wdCell, 1
    wrdApp.Selection.InsertAfter ExistingFrench
    '
    ' Move to the next cell to the right, for Item_ID
    '
    wrdApp.Selection.Move wdCell, 1
    wrdApp.Selection.InsertAfter Item_ID
  Else
    '
    '   Code snipped
    '
All this has been working beautifully in Office 2003 and Office 2010 for several years. Now along comes 2013 and it falls apart.

The procedure to fails at the highlighted line in Write_Item, and I have no idea why. All I get is the wonderfully informative error "Microsoft Word has stopped working" and Word closes. I have turned off all VBA error trapping, but I get nothing more. Changing the bookmark name to a non-existent one didn't result in anything different.

I moved the MS Word object library up as far as I could in the References list, but no luck there, either.

Does anyone have any ideas to where I should at least start to look? (or should I go looking for the Microsoft development team....?)

Thanks in advance.

John