Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default starting Word with an Excel macro

I found this piece of code that opens Word from within an Excel macro
Private Sub Open_word_run_build_directory()
Dim oWord As Object
Dim oDoc As Object
Dim wpath As String
wpath = ActiveWorkbook.Path
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Open(wpath & "\build directory V6.doc")
End Sub

The Word doc €˜build directory V6.doc has a VBA macro in an AutoOpen
subroutine that executes when it opens. Everything works fine except Excel
closes after executing the above routine. I would like it to stay open.
Nothing in the Excel code that follows the above subroutine is the cause of
Excel closing so I have to assume that something about this routine is
causing it or perhaps Excel VBA and Word VBA cannot execute at the same time.
Any thoughts on this?

--
russ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default starting Word with an Excel macro

There is nothing in the code you posted that would cause Excel to close.
Did you check the Document.Open event of your word document to see if it has
something that might close other applications?


"Russ" wrote in message
...
I found this piece of code that opens Word from within an Excel macro
Private Sub Open_word_run_build_directory()
Dim oWord As Object
Dim oDoc As Object
Dim wpath As String
wpath = ActiveWorkbook.Path
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Open(wpath & "\build directory V6.doc")
End Sub

The Word doc 'build directory V6.doc' has a VBA macro in an AutoOpen
subroutine that executes when it opens. Everything works fine except
Excel
closes after executing the above routine. I would like it to stay open.
Nothing in the Excel code that follows the above subroutine is the cause
of
Excel closing so I have to assume that something about this routine is
causing it or perhaps Excel VBA and Word VBA cannot execute at the same
time.
Any thoughts on this?

--
russ



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default starting Word with an Excel macro

If you don't want code to run when you open a doc, put this around the code
where you open the document

oWord.AutomationSecurity =msoAutomationSecurityLow
oWord.AutomationSecurity = msoAutomationSecurityByUI

--
HTH,

Barb Reinhardt



"Russ" wrote:

I found this piece of code that opens Word from within an Excel macro
Private Sub Open_word_run_build_directory()
Dim oWord As Object
Dim oDoc As Object
Dim wpath As String
wpath = ActiveWorkbook.Path
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Open(wpath & "\build directory V6.doc")
End Sub

The Word doc €˜build directory V6.doc has a VBA macro in an AutoOpen
subroutine that executes when it opens. Everything works fine except Excel
closes after executing the above routine. I would like it to stay open.
Nothing in the Excel code that follows the above subroutine is the cause of
Excel closing so I have to assume that something about this routine is
causing it or perhaps Excel VBA and Word VBA cannot execute at the same time.
Any thoughts on this?

--
russ

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
starting Word from an Excel macro Russ Excel Programming 3 November 23rd 09 06:18 PM
Need macro that delete rows starting with specified letter/word andrei Excel Programming 2 September 27th 09 02:49 PM
keyboard is locked after starting in both word and excel kfaul Excel Discussion (Misc queries) 0 November 18th 08 03:48 PM
Starting Word from Excel AndyC812 Excel Programming 2 June 14th 08 05:57 PM
Starting Excel from Word MichaelS_[_6_] Excel Programming 4 March 3rd 06 03:50 PM


All times are GMT +1. The time now is 12:24 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"