Assign Read Only attribute a document

G

Greg@InnaPhase

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
 
P

Peter Hewett

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:
 
G

Greg@InnaPhase

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
 
P

Peter Hewett

Hi Greg@InnaPhase

I'm still not sure I have it all straight so here's what I think you want, if
I'm wrong please correct me.

1. Your code produces a document.
2. Your code then displays a Form. The Form gives the user the choice of
sending the document to a secure server or Canceling the form and editing the
document.
3. If the document is sent to a secure server the user should not be able to
edit the document?
4. If the user edits the document (and presumably displays your Form some how)
they should not be able to send it to the secure server. In other words we need
to know that it's been edited.

Have I missed anything out either?

Cheers - Peter


(e-mail address removed) (Greg@InnaPhase), said:
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:

HTH + Cheers - Peter
 
G

Greg@InnaPhase

Peter,

Again you are correct in your assessment. I am generating a document
and then presenting a form to the user with the choices to send with
no edits, or to not send and edit and save to any location other than
the secure directory.

I'm not the originator of the code but what I think is happening is
that the code makes a copy of the document and gives it a life of it's
own. Then the document is by default open to edits. The code then
just saves and sends whatever is in the document.

I figured if I could make the document Read-Only when it was opened
then I could give the user the option to open it and edit, thereby
making the document Write.


Cheers,

Greg



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:
 
P

Peter Hewett

Hi Greg@InnaPhase

Unfortunately I don't have the time to look at your code in detail. You're going to have
to work through what it does and how it does it yourself. I can however, offer advice on
what it should be doing!!

We pick up the pieces from when the code has created a document, so everything I say
assumes that this step has been completed.

The first thing you need to do is add a document Variable (DV) to the Document that's just
been created. This is so that you can determine whether the document is subsequently
modified! Lets call this DV "_Clean". When you create it set it's initial value to True.
Because adding a DV to a Document actually dirties the document you then need to reset the
Documents.Saved property to True. It is absolutely essential that these are the last
things you do to the Document as we are going to used the Documents Saved property to
detect further changes.

However, we can't just rely on the Document Saved property. Take the case where a user
modifies the document and then saves it to a non secure location. Then opens the document
and saves it to the secure location! As soon as you open a document or save a document
Word resets it's saved property to True. So we also need an additional flag (the DV) to
determine if the document was previously edited.

You also need to implement the following macros in your template so that you can detect
whether the document has been modified and control whether the document should be saved or
not:

1. FileSave
2. FileSaveAs
3. FileSaveAll
4. FileVersions

This somewhat circuitous path allows the user to save the document locally and if they do
not change it, they can subsequently save it to your secure server.

The first things all of the above macros do is check the Documents Saved property. If
it's Saved property is False (the document has been modified) then you update the DV
"_Clean" to False. If the Saved property is True you then check that the DV "_Clean" is
True.

If both conditions are True then they can save the document anywhere (including the secure
server) they want as the document has never been changed. If either of these 2 conditions
is False then they can save the document anywhere but the secure server.

Sorry I've given you hints, etc on what you need to do but I don't have the time to go
into this at real depth. You may wish to think through what I've said to make sure there
are no conceptual holes in it. Once you're satisfied that it's ok then you need to work
out how you integrate the above into your existing code.

I'd tackle it a piece at a time and get each piece working. If you need more information
post again requesting help on a specific topic, that way others can respond to your
queries as well.

Good luck, and I hope the above is of some help + Cheers - Peter


(e-mail address removed) (Greg@InnaPhase), said:
Peter,

Again you are correct in your assessment. I am generating a document
and then presenting a form to the user with the choices to send with
no edits, or to not send and edit and save to any location other than
the secure directory.

I'm not the originator of the code but what I think is happening is
that the code makes a copy of the document and gives it a life of it's
own. Then the document is by default open to edits. The code then
just saves and sends whatever is in the document.

I figured if I could make the document Read-Only when it was opened
then I could give the user the option to open it and edit, thereby
making the document Write.


Cheers,

Greg



[email protected] (Greg@InnaPhase) wrote in message news: said:
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

HTH + Cheers - Peter
 
G

Greg@InnaPhase

Thanks Peter. You're guidance has been more than helpful. I'm sure I
will be able to resolve the problem now.

Again,

Many thanks,

Greg

Peter Hewett said:
Hi Greg@InnaPhase

Unfortunately I don't have the time to look at your code in detail. You're going to have
to work through what it does and how it does it yourself. I can however, offer advice on
what it should be doing!!

We pick up the pieces from when the code has created a document, so everything I say
assumes that this step has been completed.

The first thing you need to do is add a document Variable (DV) to the Document that's just
been created. This is so that you can determine whether the document is subsequently
modified! Lets call this DV "_Clean". When you create it set it's initial value to True.
Because adding a DV to a Document actually dirties the document you then need to reset the
Documents.Saved property to True. It is absolutely essential that these are the last
things you do to the Document as we are going to used the Documents Saved property to
detect further changes.

However, we can't just rely on the Document Saved property. Take the case where a user
modifies the document and then saves it to a non secure location. Then opens the document
and saves it to the secure location! As soon as you open a document or save a document
Word resets it's saved property to True. So we also need an additional flag (the DV) to
determine if the document was previously edited.

You also need to implement the following macros in your template so that you can detect
whether the document has been modified and control whether the document should be saved or
not:

1. FileSave
2. FileSaveAs
3. FileSaveAll
4. FileVersions

This somewhat circuitous path allows the user to save the document locally and if they do
not change it, they can subsequently save it to your secure server.

The first things all of the above macros do is check the Documents Saved property. If
it's Saved property is False (the document has been modified) then you update the DV
"_Clean" to False. If the Saved property is True you then check that the DV "_Clean" is
True.

If both conditions are True then they can save the document anywhere (including the secure
server) they want as the document has never been changed. If either of these 2 conditions
is False then they can save the document anywhere but the secure server.

Sorry I've given you hints, etc on what you need to do but I don't have the time to go
into this at real depth. You may wish to think through what I've said to make sure there
are no conceptual holes in it. Once you're satisfied that it's ok then you need to work
out how you integrate the above into your existing code.

I'd tackle it a piece at a time and get each piece working. If you need more information
post again requesting help on a specific topic, that way others can respond to your
queries as well.

Good luck, and I hope the above is of some help + Cheers - Peter


(e-mail address removed) (Greg@InnaPhase), said:
Peter,

Again you are correct in your assessment. I am generating a document
and then presenting a form to the user with the choices to send with
no edits, or to not send and edit and save to any location other than
the secure directory.

I'm not the originator of the code but what I think is happening is
that the code makes a copy of the document and gives it a life of it's
own. Then the document is by default open to edits. The code then
just saves and sends whatever is in the document.

I figured if I could make the document Read-Only when it was opened
then I could give the user the option to open it and edit, thereby
making the document Write.


Cheers,

Greg



[email protected] (Greg@InnaPhase) wrote in message news: said:
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




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

HTH + Cheers - Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top