[AccessD] Word Doc populated from Access but not opening with normal options

Max Wanadoo max.wanadoo at gmail.com
Thu Nov 12 08:08:30 CST 2009


Hi List,
I have a word document which has properties populated from an Access
record.  The document opens ok, but there are no menu options shown,
no file options, no print options, etc.  Just blank borders.

The code I suspect is the problem is this bit, but I have put the full
code below in case anybody can see any other problem.  It may be the
wdWindowStateNormal which is wrong.

    With appWord
        .ActiveDocument.SaveAs strSaveNamePath
        .ActiveWindow.WindowState = wdWindowStateNormal
        .Visible = True
        .Activate
    End With

Can anybody throw any light on this?
Thanks
Max
    'Get template path from Word Options dialog
    Set appWord = GetObject(, "Word.Application")
    'Create a new document from template and set doc property values
    Set doc = appWord.Documents.Add(strPathTemplatesServer)
    With appWord.ActiveDocument.Bookmarks
        .Item("TID").Range.Text = "TID/" & CStr(lngOrgID)
        .Item("Date").Range.Text = CStr(Format(Date, "d mmmm yyyy"))
        .Item("Addr").Range.Text = Trim(strAddr)
        .Item("Salutation").Range.Text = Trim(strSalutation)
    End With

    'Save document and make it visible
    Dim intCount As Integer, bSaveNameFail As Boolean
    intCount = 1
    bSaveNameFail = True
    strDocsPath = "\\server\Z\OrgLetters\"
    strSearchName = ""
    Do While bSaveNameFail
        strSaveName = modGetSaveName(intCount, strSearchName, lngOrgID)
        strSaveNamePath = strDocsPath & strSaveName
        strTestFile = Nz(Dir(strSaveNamePath))
        If strTestFile = strSaveName Then  ' already have this name on
disk, create a new name
            bSaveNameFail = True: intCount = intCount + 1
        Else
            bSaveNameFail = False
        End If
    Loop

    ' record the letter being sent
    Call modLettersSent(strSaveNamePath, "frmTrustsShortLetters", , lngOrgID)

    With appWord
        .ActiveDocument.SaveAs strSaveNamePath
        .ActiveWindow.WindowState = wdWindowStateNormal
        .Visible = True
        .Activate
    End With



More information about the AccessD mailing list