LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 469
Default Hyperlink to open Word File

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retaining formats grok Excel Discussion (Misc queries) 11 October 31st 06 07:29 PM
Can not open excel file xls. extensions cjshazen Excel Discussion (Misc queries) 1 February 14th 06 01:17 AM
cannot open excel file, please help!!! sunlite Excel Discussion (Misc queries) 0 September 5th 05 05:29 PM
Excel startup switches Randy Excel Discussion (Misc queries) 9 June 14th 05 10:27 PM
Hyperlink in Excel 2000 can't open bookmarked Word 2000 file DCheslock Excel Discussion (Misc queries) 1 May 5th 05 10:46 PM


All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"