Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default excel macro to open word doc besed on user selection

Two things I noticed:

1. Range("P2") would need to contain the complete path, including the file
name.
2. The syntax for this:
oWord.Documents.Open Name = p
should be this:
oWord.Documents.Open FileName:= p



"Looper" wrote in message
...
I need to create a macro to be run from excel that will open a word
document.
The name of the word document will be defined by the user and is vaiable
based on user input. I have very limited VB experience and can be
classified
as a "cut and paste guy"

through trial and error i have assembled the code below which doesnt work.
Please supply easily understood answer.

Thank you,

Sub OpenWordDocumentFromExcel()

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim p As String
Sheets("lists").Visible = True
Sheets("lists").Select
p = Range("p2").Value
Sheets("lists").Visible = False

'On Error GoTo BadShow
Dim oWord As Object
Set oWord = CreateObject("Word.application")
oWord.Documents.Open Name = p
oWord.Visible = True
AppActivate oWord
Set oWord = Nothing
Exit Sub
'BadShow:
'oWord.Quit
Set oWord = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub





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
Macro to Open Word from Excel Micah Excel Programming 0 October 26th 06 03:28 PM
open word macro from excel A1pro Excel Programming 1 October 19th 06 04:46 PM
Open Word Doc From Excel Macro MATT Excel Discussion (Misc queries) 4 December 14th 04 12:09 AM
open Word from excel Macro hurst,j Excel Worksheet Functions 0 December 2nd 04 03:27 PM
Graph Excel Selection, Open Word File, Embed Graph Into Word Steve Excel Programming 0 November 17th 03 05:35 PM


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

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"