Excellent assessment!
The section of code that I posted originally is in part responsible
for generating a document that through the form frmExport.Show lets
the user decide to export the document out to a folder or to cancel
and edit the document.
My quandry stems from the fact that the document is presented to the
user in Read-Write mode while they decide to send it off to a secure
folder. I want to remove that edit capability, or if they do edit the
document, it will not allow them to send it to the secure location.
I thought of making the frmExport.show modal but the user can still
click beyond the dialog, edit and save the edits to the secure
location. Not what I want.
I've included all of the VBA for the REPORT below.
Thanks for your help. It is greatly appreciated.
Greg
Option Explicit
Private ProtocolChapterName As String
Private ChaptersStrings As Collection
Private MyMacros As MyMacroUtil
Public CancelMe As Boolean
'---------------------------------------------------------
' BMReplace utility Function
'---------------------------------------------------------
Private Sub BMReplace(BMSource As String, BMDest As String)
On Error GoTo Error_handler
Me.SourceDocument.Bookmarks.Item(BMSource).Select
Me.SourceDocument.Bookmarks.Item(BMSource).Range.Copy
Me.FinalDocument.Bookmarks.Item(BMDest).Select
Me.FinalDocument.Bookmarks.Item(BMDest).Range.Paste
Exit Sub
Error_handler:
MsgBox Err.Description, , "Alcon VBA Script"
Exit Sub
End Sub
'---------------------------------------------------------
' AddChapterString utility Function
'---------------------------------------------------------
Private Sub AddChapterString(C As String, S As String)
Dim Obj As New clsChapterString
Call Obj.Add(C, S)
Call ChaptersStrings.Add(Obj)
Set Obj = Nothing
End Sub
'---------------------------------------------------------
' IsThisChapterToPlay utility Function
'---------------------------------------------------------
Private Function IsThisChapterToPlay(ChapterName As String) As Boolean
Dim Obj As clsChapterString
For Each Obj In ChaptersStrings
If ChapterName = Obj.ChapterToPlayWith Then
IsThisChapterToPlay = True
Exit Function
End If
Next
End Function
Private Sub Report_AfterChapterPrint(ChapterName As String)
End Sub
'---------------------------------------------------------
'
' Report events:
'
'---------------------------------------------------------
Private Sub Report_AfterReportReady()
On Error Resume Next
Dim Obj As clsChapterString
Dim p As Object
Dim bresult As Integer
For Each Obj In ChaptersStrings
Call MyMacros.FindAndReplace(Obj.StringToFind,
Obj.ChapterToPlayWith, Me.FinalDocument)
Next
Me.FinalDocument.Fields
Set ChaptersStrings = Nothing
Set MyMacros = Nothing
bresult = MsgBox("Would you like to send this Report to
Documentum?", vbYesNo, "Export Report?")
If bresult = vbNo Then
Exit Sub
Else
frmExport.Show
End If
End Sub
Private Sub Report_BeforeChapterPrint(ChapterName As String)
Dim wd As Object
On Error Resume Next
Call AddCustomProps
If IsThisChapterToPlay(ChapterName) Then
If MyMacros Is Nothing Then
Set MyMacros = New MyMacroUtil
End If
If MyMacros.SaveDoc(ChapterName, Me.SourceDocument) = False
Then
MsgBox "Cannot save " & ChapterName & " to temporary file"
Else
Set wd = Me.SourceDocument
wd.Select
wd.Sections(1).Range.Text = ""
End If
End If
If Left(ChapterName, Len(ProtocolChapterName)) =
ProtocolChapterName Then
Call ReplaceProtocolBookmarks
' Clean up Protocol chapter because we don't need to print it
Me.SourceDocument.Select
Me.SourceDocument.Range.Text = ""
End If
End Sub
Private Sub ReplaceProtocolBookmarks()
End Sub
Private Sub Report_BeforeChapterTextPrint(ChapterName As String, Text
As String)
End Sub
Private Sub Report_BeforeReportReady()
frmProtocolName.Show vbModal
ProtocolChapterName = frmProtocolName.ProtocolChapterName
Unload frmProtocolName
Set ChaptersStrings = Nothing
Set ChaptersStrings = New Collection
Call AddChapterString("Summary", "[Placeholder for Summary]")
End Sub
Public Sub AddCustomProps()
Dim CDP As Object
Dim p As Object
On Error Resume Next
For Each CDP In Me.SourceDocument.CustomDocumentProperties
' check for presence of this property
For Each p In Me.FinalDocument.CustomDocumentProperties
If p.Name = CDP.Name Then
p.Value = CDP.Value
GoTo SkipThisOne
End If
Next p
Call Me.FinalDocument.CustomDocumentProperties.Add(CDP.Name,
False, CDP.Type, CDP.Value)
SkipThisOne:
Next
End Sub
Peter Hewett said:
Hi Greg@InnaPhase
I don't understand what you mean by <convey READ-ONLY attributes for review>
maybe you can expound on this for us?
Also we don't have reference to your project, so I don't know where your code is
or how it is called or what references such as "FinalDocument" and
"FinalDocument.Fields". I can tell form the syntax that this code is in a Form
or Class module, likewise FinalDocument is a Property or Function and Fields is
a Method. But as to what they do????
Once you explain the first part the rest may become redundant, but all I have at
the moment is questions, rather than answers for you.
HTH + Cheers - Peter
(e-mail address removed) (Greg@InnaPhase), said:
I am using the code below to convey READ-ONLY attributes for review
before sending it to a secure directory. I am trying everything I can
think of but I can still save any edits to the document before sending
it.
This is the code that I'm using but it has no READ-ONLY attributes.
Can you please give me a hint of where I can focus my attributes for
the document?
Any help is greatly appreciated.
Greg (Code Below)
Private Sub Report_AfterReportReady()
On Error Resume Next
Dim Obj As clsChapterString
Dim p As Object
Dim bresult As Integer
For Each Obj In ChaptersStrings
Call MyMacros.FindAndReplace(Obj.StringToFind,
Obj.ChapterToPlayWith, Me.FinalDocument)
Next
Me.FinalDocument.Fields
Set ChaptersStrings = Nothing
Set MyMacros = Nothing
bresult = MsgBox("Would you like to send this Report to
Documentum?", vbYesNo, "Export Report?")
If bresult = vbNo Then
Exit Sub
Else
frmExport.Show
End If
End Sub