View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Label Click to open Word Document

Here's one that I saved:

Option Explicit
Sub testme()

'Dim WDApp As Word.Application
'Dim WDDoc As Word.Document
Dim WDApp As Object
Dim WDDoc As Object
Dim myDocName As String
Dim WordWasRunning As Boolean
Dim testStr As String

myDocName = "C:\my documents\word\doc10.doc"

testStr = ""
On Error Resume Next
testStr = Dir(myDocName)
On Error GoTo 0
If testStr = "" Then
MsgBox "Word file not found!"
Exit Sub
End If

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

WDApp.Visible = True 'at least for testing!

Set WDDoc = WDApp.documents.Open(Filename:=myDocName)

'do more stuff????

'If WordWasRunning Then
' 'leave it running
'Else
' WDApp.Quit
'End If

Set WDDoc = Nothing
Set WDApp = Nothing

End Sub

NateBuckley wrote:

Hello, I want to be able to click on a label in a userform and do something
in the

_Click event that will open a word document.

Something like this

OpenWord(thisWorkBook.Path & "/guide/guide.doc")

I know this Function "OpenWord" doesn't exist, just wondering if anything
like it.

Thanks in advance!


--

Dave Peterson