Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DECIPHER BROWSER: IE vs. Winword 1

Status
Not open for further replies.

LikeThisName

Vendor
May 16, 2002
288
US
an unusual request, may have many solutions, i'm aware of two ways, one i know how to do the other i think i should be able to do but don't know how.

WHAT I NEED:
make a document available for read only on intranet but editable through pc-docs/Word.

SOLUTION 1 (i know this way)
on exiting/saving document in word I automatically save document again as read only and just reference the read only version on the intranet.

SOLUTION 2 (don't know this way)
have one file, and upon opening detect if its opened in IE. if it is make read-only, if not do nothing.

I am open to any suggestions, i'll post the code for solution one later today.

LikeThisName <- ? Sorry It's Taken =)
 
Code:
Private Sub Document_Close()
On Error GoTo err_handle
Dim fname As String

fname = "ro" & ActiveDocument.Name

SetAttr fname, vbNormal 'unprotect

ActiveDocument.SaveAs _
      FileName:=fname

SetAttr fname, vbReadOnly 'reprotect
MsgBox "read only version updated"
err_handle:
Select Case Err.Number
    Case 5155 'if a read only file doesn't exist
        Exit Sub
    Case 0, 20
        Resume Next
    Case Else
        MsgBox Err.Number & Err.Description
End Select
End Sub

a variation of the above was working until i tweaked it too much. only problem was it was updating read-only version on exit instead of updating if saved.

anyone know how to check if activedocument in current state equals saved state. so that i update a read only version only if file itself is saved.

or is this why solution 2 would be better? or any other solution than solution than solution 1. Any pointers highly appreciated as always,

TIA,

LikeThisName <- ? Sorry It's Taken =)
 
Something like this ?
If Not ActiveDocument.Saved Then
MsgBox "We must save the document"
End If

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
You the man PHV, thanks!

here is updated working code, before it worked but was writing to a path i was not aware of so i fixed that here:

Code:
Private Sub Document_Close()
On Error GoTo err_handle

Dim fname As String

If Not ActiveDocument.Saved Then
    MsgBox "not saved"
    Exit Sub
Else
    fname = ActiveDocument.Path & "\ro" & ActiveDocument.Name
    SetAttr fname, vbNormal

    ActiveDocument.SaveAs _
      FileName:=fname

    SetAttr fname, vbReadOnly
    MsgBox "read only version updated"
End If

err_handle:
Select Case Err.Number
    Case 5155, 53 ' there is no read-only version of this file
        Exit Sub
    Case 0, 20 ' no errors
        Resume Next
    Case Else
        MsgBox Err.Number & Err.Description
End Select
End Sub

LikeThisName <- ? Sorry It's Taken =)
 
if anyone comes by i'm still open to alternative solutions.
but again thanks phv for helping do mine correctly.

LikeThisName <- ? Sorry It's Taken =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top