Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to Open Word from Excel | Excel Programming | |||
open word macro from excel | Excel Programming | |||
Open Word Doc From Excel Macro | Excel Discussion (Misc queries) | |||
open Word from excel Macro | Excel Worksheet Functions | |||
Graph Excel Selection, Open Word File, Embed Graph Into Word | Excel Programming |