L
Looper
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
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