Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation Access to Word 1

Status
Not open for further replies.

BrianOg

Programmer
Feb 10, 2004
12
GB
Am having problems with creating a Word document from Access. I have successfully created the document but cannot get Word to remain open in order to edit the document. Part of my coding is:

Code:
DoCmd.OpenForm "frmSelectSchoolContact", , , "[fldSchool_ID] = " & Me.txtSchoolID, , acDialog

If Len(Me.txtSchoolName) < 10 Then
    strFileName = Me.txtSchoolName & Me.txtSchoolID
Else
    strFileName = Left(Me.txtSchoolName, 10) & Me.txtSchoolID
End If
    

appWord.Documents.Add strRoutePlanTemplateFolderName & "\" & strRoutePlanTemplate
appWord.Visible = True
appWord.Selection.GoTo wdGoToBookmark, NAME:="Name"
appWord.Selection.TypeText Me.txtSchoolName
appWord.Selection.GoTo wdGoToBookmark, NAME:="Phone"
appWord.Selection.TypeText Me.txtPhone
appWord.Selection.GoTo wdGoToBookmark, NAME:="Contact"
appWord.Selection.TypeText Me.txtContact
appWord.ActiveDocument.SaveAs strRoutePlanFolderName & "\" & strFileName
appWord.Documents.Open strRoutePlanFolderName & "\" & strFileName
appWord.Selection.GoTo wdGoToBookmark, NAME:="Start"
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblSchools SET tblSchools.fldRoutePlanner = " & strRoutePlanFolderName & "\" & strFileName & _
             " WHERE ((tblSchools.fldSCHOOL_ID)= " & Me.txtSchoolID & ");"
DoCmd.SetWarnings True
DoCmd.Close
appWord.Quit
Set appWord = Nothing

Problem is that Word closes, even though I reopen the saved document and place the cursor on a bookmark in it where I want the data to be entered (manually)

Would be grateful for anyone's help
Regards
Brian
NB have left out some non-relevant coding
 
[tt]appWord.Quit[/tt] - will quit (close) word, remove that line, and Word should continue to be open.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top