M
mleviton
I am using an Access db to populate an excel and a word document, print
them, and then close. When it runs, the user should not be promted to
save changes when the documents close. The code includes
"objWord.Documents("timesheet.doc").Close SaveChanges = False" and
works on the win2000 server but the win2003 server prompts the user to
save changes. Here is a portion of the code:
objWord.Visible = True
objWord.Documents.Open ("F:\database\timesheet\timesheet.doc")
objWord.WindowState = wdWindowStateMaximize
rs.MoveFirst
'Insert Timesheet information
objWord.Selection.GoTo What:=wdGoToBookmark, Name:="bkmTDate"
Do While Not rs.EOF
objWord.Selection.Text = rs!TDate
objWord.Selection.MoveRight unit:=wdCell
objWord.Selection.Text = rs!DocketID
objWord.Selection.MoveRight unit:=wdCell
objWord.Selection.Text = rs!Time
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TCode1) Then
objWord.Selection.Text = rs!TCode1
Else
objWord.Selection.Text = "0"
End If
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TCode2) Then
objWord.Selection.Text = rs!TCode2
Else
objWord.Selection.Text = "0"
End If
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TCode3) Then
objWord.Selection.Text = rs!TCode3
Else
objWord.Selection.Text = "0"
End If
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TCode4) Then
objWord.Selection.Text = rs!TCode4
Else
objWord.Selection.Text = "0"
End If
'objWord.Selection.Goto What:=wdGoToBookmark,
Name:="bkmNotes"
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TText) Then objWord.Selection.Text =
rs!TText
objWord.Selection.MoveRight unit:=wdCell
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = CurrentProject.Connection
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "SELECT * FROM tblTimesheetMaster WHERE
TimesheetMasterID = " & strMasterID & ";"
End With
rs.MoveFirst
If Not IsNull(rs!Comments) Then
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmComment"
objWord.Selection.Text = rs!Comments
End If
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmEmployee"
objWord.Selection.Text = rs!EmployeeName
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmHours"
objWord.Selection.Text = rs!TotalHours
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmStartDate"
objWord.Selection.Text = rs!PPBegin
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmEndDate"
objWord.Selection.Text = rs!PPEnd
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmEmpNo"
objWord.Selection.Text = rs!EmployeeID
objWord.Selection.HomeKey unit:=wdStory
If booAllPages Then
objWord.ActiveDocument.PrintOut
Else
objWord.ActiveDocument.PrintOut
Range:=wdPrintRangeOfPages, Pages:=strPages
End If
objWord.Documents("timesheet.doc").Close SaveChanges =
False
If Not booWordOpen Then
objWord.Quit
End If
Set objWord = Nothing
rs.Close
Set rs = Nothing
MergeIt = True
End If
End Sub
Any suggestions would be greatly appreciated. Thanks, PPT
them, and then close. When it runs, the user should not be promted to
save changes when the documents close. The code includes
"objWord.Documents("timesheet.doc").Close SaveChanges = False" and
works on the win2000 server but the win2003 server prompts the user to
save changes. Here is a portion of the code:
objWord.Visible = True
objWord.Documents.Open ("F:\database\timesheet\timesheet.doc")
objWord.WindowState = wdWindowStateMaximize
rs.MoveFirst
'Insert Timesheet information
objWord.Selection.GoTo What:=wdGoToBookmark, Name:="bkmTDate"
Do While Not rs.EOF
objWord.Selection.Text = rs!TDate
objWord.Selection.MoveRight unit:=wdCell
objWord.Selection.Text = rs!DocketID
objWord.Selection.MoveRight unit:=wdCell
objWord.Selection.Text = rs!Time
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TCode1) Then
objWord.Selection.Text = rs!TCode1
Else
objWord.Selection.Text = "0"
End If
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TCode2) Then
objWord.Selection.Text = rs!TCode2
Else
objWord.Selection.Text = "0"
End If
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TCode3) Then
objWord.Selection.Text = rs!TCode3
Else
objWord.Selection.Text = "0"
End If
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TCode4) Then
objWord.Selection.Text = rs!TCode4
Else
objWord.Selection.Text = "0"
End If
'objWord.Selection.Goto What:=wdGoToBookmark,
Name:="bkmNotes"
objWord.Selection.MoveRight unit:=wdCell
If Not IsNull(rs!TText) Then objWord.Selection.Text =
rs!TText
objWord.Selection.MoveRight unit:=wdCell
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = CurrentProject.Connection
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "SELECT * FROM tblTimesheetMaster WHERE
TimesheetMasterID = " & strMasterID & ";"
End With
rs.MoveFirst
If Not IsNull(rs!Comments) Then
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmComment"
objWord.Selection.Text = rs!Comments
End If
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmEmployee"
objWord.Selection.Text = rs!EmployeeName
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmHours"
objWord.Selection.Text = rs!TotalHours
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmStartDate"
objWord.Selection.Text = rs!PPBegin
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmEndDate"
objWord.Selection.Text = rs!PPEnd
objWord.Selection.GoTo What:=wdGoToBookmark,
Name:="bkmEmpNo"
objWord.Selection.Text = rs!EmployeeID
objWord.Selection.HomeKey unit:=wdStory
If booAllPages Then
objWord.ActiveDocument.PrintOut
Else
objWord.ActiveDocument.PrintOut
Range:=wdPrintRangeOfPages, Pages:=strPages
End If
objWord.Documents("timesheet.doc").Close SaveChanges =
False
If Not booWordOpen Then
objWord.Quit
End If
Set objWord = Nothing
rs.Close
Set rs = Nothing
MergeIt = True
End If
End Sub
Any suggestions would be greatly appreciated. Thanks, PPT