Okay, I updated my code as you showed me (using my fields); now I get a
Run-time error '2455':
You entered an expression that has an invalid reference to the property
Selected.
The debug points to the line:
If lstName.Selected(intCurrentRow) Then
The full code (sorry it's so long!) is:
Public Sub CreateSCIDRequestDoc(lstName As Control, lstUsersProfile As
Control, _
lstUsersAssignmentGrp As Control,
txtUsersName As String)
Static WordObj As Word.Application
Dim strSaveDir As String
Dim strFileName As String
Dim intCurrentRow As Integer
For intCurrentRow = 0 To lstName.ListCount - 1
If lstName.Selected(intCurrentRow) Then
Debug.Print lstName.Column(0, intCurrentRow)
strSaveDir = "K:\DATA\PRIVATE\Iscs\ServiceCenter\SCUserIDRequests\"
strFileName = "User ID Request for " & txtUsersName & ".doc"
Set WordObj = Nothing
Set WordObj = CreateObject("Word.Application")
With WordObj
WordObj.Documents.Open (m_strDIR & m_strTEMPLATE)
WordObj.Visible = True
.ActiveDocument.Bookmarks("Participant").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtUsersName))
.ActiveDocument.Bookmarks("LoginID").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtUsersLoginID))
.ActiveDocument.Bookmarks("LocalPhone").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtUsersPhone))
.ActiveDocument.Bookmarks("SunComPhone").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtSunCom))
.ActiveDocument.Bookmarks("Department").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtUsersDept))
.ActiveDocument.Bookmarks("Section").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtUsersSection))
.ActiveDocument.Bookmarks("Manager").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!lstName))
.ActiveDocument.Bookmarks("Room").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtUsersRoom))
.ActiveDocument.Bookmarks("Profile").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!lstUsersProfile))
.ActiveDocument.Bookmarks("AssignmentGroup").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!
lstUsersAssignmentGrp))
.ActiveDocument.Bookmarks("RequestorsName").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!lstName))
.ActiveDocument.Bookmarks("Title").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtRequestorsTitle))
.ActiveDocument.Bookmarks("Agency").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtRequestorsAgency))
.ActiveDocument.Bookmarks("OfficeAcronym").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtRequestorsOffice))
.ActiveDocument.Bookmarks("RequestorsPhone").Select
.Selection.Text = (CStr(Forms!frmNewEmplSecurity6!txtRequestorsPhone))
End With
End If
Next intCurrentRow
WordObj.ActiveDocument.SaveAs FileName:=strSaveDir & strFileName
End Sub
Help!! =)
+Tammy