ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   starting Word from an Excel macro (https://www.excelbanter.com/excel-programming/436532-starting-word-excel-macro.html)

Russ

starting Word from an Excel macro
 
I found this piece of code by Bob Phillips that opens a Word document from
within an Excel macro.
Dim oWord as Object
Dim oDoc as Object

Set oWord = CreateObject("Word.Application")
oWord.Visible = True

Set oDoc = oWord.Documents.Open("C:\personal\bob\personal\CV - RP
(short).doc")

It works fine but it also closes the Excel file that contains the macro. Is
there a way to prevent the Excel file from closing?
--
russ

Mike H

starting Word from an Excel macro
 
Russ,

There's nothing in that snippet that will close the Excel Application. I
think you need to post all your code.

Mike

"Russ" wrote:

I found this piece of code by Bob Phillips that opens a Word document from
within an Excel macro.
Dim oWord as Object
Dim oDoc as Object

Set oWord = CreateObject("Word.Application")
oWord.Visible = True

Set oDoc = oWord.Documents.Open("C:\personal\bob\personal\CV - RP
(short).doc")

It works fine but it also closes the Excel file that contains the macro. Is
there a way to prevent the Excel file from closing?
--
russ


Gord Dibben

starting Word from an Excel macro
 
Nothing I can see in that code would cause Excel or the workbook to close.

Lose focus, yes, close, no.

At least not in my testing.


Gord Dibben MS Excel MVP

On Mon, 23 Nov 2009 09:10:02 -0800, Russ
wrote:

I found this piece of code by Bob Phillips that opens a Word document from
within an Excel macro.
Dim oWord as Object
Dim oDoc as Object

Set oWord = CreateObject("Word.Application")
oWord.Visible = True

Set oDoc = oWord.Documents.Open("C:\personal\bob\personal\CV - RP
(short).doc")

It works fine but it also closes the Excel file that contains the macro. Is
there a way to prevent the Excel file from closing?



Dave Peterson

starting Word from an Excel macro
 
What version of excel are you using?

Russ wrote:

I found this piece of code by Bob Phillips that opens a Word document from
within an Excel macro.
Dim oWord as Object
Dim oDoc as Object

Set oWord = CreateObject("Word.Application")
oWord.Visible = True

Set oDoc = oWord.Documents.Open("C:\personal\bob\personal\CV - RP
(short).doc")

It works fine but it also closes the Excel file that contains the macro. Is
there a way to prevent the Excel file from closing?
--
russ


--

Dave Peterson


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com