View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Curt Curt is offline
external usenet poster
 
Posts: 469
Default Hyperlink to open Word File

Dave:
Just to let you know it does work.
Problem: Don't know how this is went to another computer and file came up as
desc.doc.doc on my computer it showed desc.doc. So now I am go to try to
finish.
Thanks so much for your support.



"Dave Peterson" wrote:

If you're getting a message like:

A:\desc.doc doesn't exist

Then you don't have a disk in drive A that contains the file named desc.doc in
the root directory.

Maybe it's a typo in the name or maybe you forgot to enter the folder name????

ps. It's a pretty bad idea to work directly off the A: drive for any office
application. I'd put that file somewhere on a harddrive or a network drive.

Curt wrote:

copied your code removed some even befor removal got error file not found. I
must be doing something wrong can not seem to locate error. Would you look at
code and see if you can locate error. Noted in post reply that it worked fine.
Thanks

Option Explicit

Sub test_Desc1()

Dim oWord As Object
Dim myWordDocName As String
Dim testStr As String

myWordDocName = "A:\desc.doc"

testStr = ""
On Error Resume Next
testStr = Dir(myWordDocName)
On Error GoTo 0
If testStr = "" Then
MsgBox myWordDocName & " doesn't exist"
Exit Sub
End If

On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number < 0 Then
Set oWord = CreateObject("Word.Application")
End If

oWord.Visible = True
oWord.Documents.Open myWordDocName, ReadOnly:=True

Set oWord = Nothing

End Sub

"Dave Peterson" wrote:

Maybe you could use a macro to open the document readonly.


Option Explicit
Sub testme()

Dim oWord As Object
Dim myWordDocName As String
Dim testStr As String

myWordDocName = "c:\my documents\word\test.doc"
'or even point to a name in the worksheet
'myWordDocName = ActiveSheet.Range("b1").Value

testStr = ""
On Error Resume Next
testStr = Dir(myWordDocName)
On Error GoTo 0
If testStr = "" Then
MsgBox myWordDocName & " doesn't exist"
Exit Sub
End If

On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.number < 0 Then
Set oWord = CreateObject("Word.Application")
End If

oWord.Visible = True
oWord.Documents.Open myWordDocName, ReadOnly:=True

Set oWord = Nothing

End Sub

You could use a button from the forms toolbar and assign it this macro.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

cartman101 wrote:

I have set up a hyperlink in Excel to pen a word file. However the word file
is set to give the read only prompt with option of a password to modify the
document.
I want to open the file read only but would prefer not to have the dialoge
box when the file is opened from within Excel.

Is there any way to modify the Hyperlink to allow this?

Alternate methods of achieving the same outcome are always welcome.

Regards

Mike

--

Dave Peterson


--

Dave Peterson