• Need code to set doc. to read only and vs (Office 2000 Word SR-1)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Need code to set doc. to read only and vs (Office 2000 Word SR-1)

    Author
    Topic
    #376690

    Hi,

    How can I make a code in a template when I want to change “Read Only” to “not Read Only” and back to “Read Only” again?

    Thanks in advance!

    Regards
    Bj

    Viewing 0 reply threads
    Author
    Replies
    • #617940

      Can you explain this a little bit more? Are you talking about protecting the document contents so the user cannot edit them (for example, in a form), or controlling whether the user can save over the original document?

      • #618000

        I have the following situation:
        A document, created by means of a template I have made, is stored and chekced in into Microsoft SharePoint Portal Server, document handling application. When published in this application the document is given the status “Read Only”. In order to release this attribute for a moment I must set the Attribute “Read Only” to “false” for a moment in the code. This to be able to set “ActiveDocument.CustomDocumentProperties(“DOCVERSION”).Value” to a number(string), retreaved from the document handling application and insert this number into tha document by means of another code.

        So I am talking about controling the attribute “Read Only”.

        Thanks if you can advice me giving a code for setting this attribute off and on.

        Regards
        Bj

        • #618008

          If you were opening this document from a file server, you would need to change the file attribute before opening the document. Once it is open, it is too late; Word will not let you save over it. I’m not sure how SharePoint works. In our DMS (WORLDOX), as far as I know, it is not possible to programmatically override the security settings (which determine who can revise and who cannot) at the file system level. Is there a documented API for SharePoint?

          • #618013

            Thanks for a quick reply.

            Here is a link to SharePoint Portal Server: http://www.microsoft.com/sharepoint/portalserver.asp

            Well,
            I had hoped that it should be able to change the read Only attribute when opening the file using the procedure: Private Sub Document_Open()
            and putting in a code for changing the attribute to not read onle and back again when getting hold of the version number. Well, as I understand it is not possible.

            Another code I am also anxious to get is:
            When I use the Word function SaveAs, by applying the procedure: Sub FileSaveAs() and insert a code to get hold of the path to the directory where I store the file and the file name.

            I use this code to open the dialog box: Dialogs(wdDialogFileSaveAs).Show
            and when I click OK I would like to get hold of the path and file name of the document(file) I save.
            Is it possible?

            Regards
            Bj

            • #618212

              [indent]


              Another code I am also anxious to get is:
              When I use the Word function SaveAs, by applying the procedure: Sub FileSaveAs() and insert a code to get hold of the path to the directory where I store the file and the file name.

              I use this code to open the dialog box: Dialogs(wdDialogFileSaveAs).Show
              and when I click OK I would like to get hold of the path and file name of the document(file) I save.
              Is it possible?


              [/indent]With this one, since no knowledge of SharePoint Portal is required, I have a better shot at being able to help! smile

              If you want to know the path AFTER the file is saved, you can find out easily as follows:

              Dialogs(wdDialogFileSaveAs).Show
              Dim strPath As String
              strPath = ActiveDocument.Path

              If strPath is blank, then the document has never been saved. However, if strPath is not blank, you can’t be sure the user saved it again…

              If you want to know BEFORE the file is saved, or resolve the uncertainty about what the user actually did in the dialog, you can do this:

              Dim strPath As String
              With Dialogs(wdDialogFileSaveAs)
                  If .Display = -1 Then   'OK was clicked
                      strPath = Options.DefaultFilePath(wdCurrentFolderPath)
                      .Execute
                  End If
              End With

              In this case, if strPath is blank, it means that the user did not save on this go-round with the Save As dialog.

              In another thread, someone reported a problem using .Display in a context in which the user chose to overwrite an existing file. Because Word doesn’t display its normal “are you sure?” dialog when .Display/.Execute are substituted for .Show, it apparently behaved strangely. I haven’t really tested that.

              Hope this helps.

            • #618406

              Thanks a lot. I will try out this.
              Bj

    Viewing 0 reply threads
    Reply To: Need code to set doc. to read only and vs (Office 2000 Word SR-1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: