Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Open Winword from Excel

Hi everyone
I found a previous post which said a MSWord document
could be opened and viewed by clicking a Command button
in Excel.
The post had this comment included, which I don't think I
fully understand.
"Assuming winword.exe is in your path statement, if not,
just include the full path statement to winword.exe."
I've included the original code plus code I've modified
to suit my folder location, names etc.
On running my code I receive an error 53 and the last
line is highlighted "Shell myApp........"
I've checked the Spelling, Paths and Capital case
characters.
Have I included the Path Statement correctly.?
Should it be on a seperate line?

Post Code
Private Sub CommandButton1_Click()
Dim myApp As String, myDoc As String
myApp = "winword.exe"
myDoc = """" & "C:\My Documents\myword.doc" & """"
Shell myApp & myDoc, vbMaximizedFocus
End Sub

My code.
Private Sub Open_Excel_Help()
Dim myApp As String, myDoc As String
myApp = "C:\Program Files\Microsoft
Office\Office10\WINWORD.EXE"
myDoc = """" & "C:\DATA\Word\EXCEL HELP.doc"
& """"
Shell myApp & myDoc, vbMaximizedFocus
End Sub

TIA
Bob Christie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Open Winword from Excel

Another option that may work for you:

Option Explicit

Sub testme01()

Dim oWord As Object
Dim myWordDocument As String
Dim testStr As String

myWordDocument = "C:\DATA\Word\EXCEL HELP.doc"

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

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

oWord.Visible = True
oWord.Documents.Open myWordDocument
AppActivate "Microsoft Word"

End Sub

Robert Christie wrote:

Hi everyone
I found a previous post which said a MSWord document
could be opened and viewed by clicking a Command button
in Excel.
The post had this comment included, which I don't think I
fully understand.
"Assuming winword.exe is in your path statement, if not,
just include the full path statement to winword.exe."
I've included the original code plus code I've modified
to suit my folder location, names etc.
On running my code I receive an error 53 and the last
line is highlighted "Shell myApp........"
I've checked the Spelling, Paths and Capital case
characters.
Have I included the Path Statement correctly.?
Should it be on a seperate line?

Post Code
Private Sub CommandButton1_Click()
Dim myApp As String, myDoc As String
myApp = "winword.exe"
myDoc = """" & "C:\My Documents\myword.doc" & """"
Shell myApp & myDoc, vbMaximizedFocus
End Sub

My code.
Private Sub Open_Excel_Help()
Dim myApp As String, myDoc As String
myApp = "C:\Program Files\Microsoft
Office\Office10\WINWORD.EXE"
myDoc = """" & "C:\DATA\Word\EXCEL HELP.doc"
& """"
Shell myApp & myDoc, vbMaximizedFocus
End Sub

TIA
Bob Christie


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Open Winword from Excel

Thanks Dave, Worked a treat.
I like the MsgBox part, I just hope it never comes up.
A lot of work went into creating an indexed help file.

Bob Christie

-----Original Message-----
Another option that may work for you:

Option Explicit

Sub testme01()

Dim oWord As Object
Dim myWordDocument As String
Dim testStr As String

myWordDocument = "C:\DATA\Word\EXCEL HELP.doc"

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

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

oWord.Visible = True
oWord.Documents.Open myWordDocument
AppActivate "Microsoft Word"

End Sub

Robert Christie wrote:

Hi everyone
I found a previous post which said a MSWord document
could be opened and viewed by clicking a Command button
in Excel.
The post had this comment included, which I don't

think I
fully understand.
"Assuming winword.exe is in your path statement, if

not,
just include the full path statement to winword.exe."
I've included the original code plus code I've modified
to suit my folder location, names etc.
On running my code I receive an error 53 and the last
line is highlighted "Shell myApp........"
I've checked the Spelling, Paths and Capital case
characters.
Have I included the Path Statement correctly.?
Should it be on a seperate line?

Post Code
Private Sub CommandButton1_Click()
Dim myApp As String, myDoc As String
myApp = "winword.exe"
myDoc = """" & "C:\My Documents\myword.doc"

& """"
Shell myApp & myDoc, vbMaximizedFocus
End Sub

My code.
Private Sub Open_Excel_Help()
Dim myApp As String, myDoc As String
myApp = "C:\Program Files\Microsoft
Office\Office10\WINWORD.EXE"
myDoc = """" & "C:\DATA\Word\EXCEL HELP.doc"
& """"
Shell myApp & myDoc, vbMaximizedFocus
End Sub

TIA
Bob Christie


--

Dave Peterson

.

Reply
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
ON OPEN VBA Code input incorrectly now excel sheet wont open mmartin New Users to Excel 1 February 16th 11 11:33 PM
Opening Excel, Book1 opens, remains open with other workbook open DanieB Excel Discussion (Misc queries) 0 September 3rd 09 08:23 AM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
EXCEL wont open from Explorer, must open EXCEL then find file wludwick Excel Discussion (Misc queries) 4 September 7th 06 08:06 PM
Open Winword-file using a Excel 97 VBA macro Dominik Scheck Excel Programming 4 August 5th 03 02:35 AM


All times are GMT +1. The time now is 12:52 PM.

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

About Us

"It's about Microsoft Excel"