Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Start MS Word?

Hi all,

I'm trying to open Microsoft Word using VBA. When I execute my code
something processes for a second but nothing happens......I have ticked the
'Microsoft Word 10.0 Object Library' box in the ToolsReferances menu. And I
have the following code:

Sub StartWord()
Dim wrdApp As Word.Application
Set wrdApp = New Word.Application
End Sub

Any ideas are appreciated....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Start MS Word?

Try

MyApp = Shell("WINWORD.EXE", vbMaximizedFocus)

Mike


"dimm" wrote:

Hi all,

I'm trying to open Microsoft Word using VBA. When I execute my code
something processes for a second but nothing happens......I have ticked the
'Microsoft Word 10.0 Object Library' box in the ToolsReferances menu. And I
have the following code:

Sub StartWord()
Dim wrdApp As Word.Application
Set wrdApp = New Word.Application
End Sub

Any ideas are appreciated....

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Start MS Word?

WrdApp.visible = true

might make you find it easier.

Here's one that I saved:

Option Explicit
Sub testme()

'Dim WDApp As Word.Application
'Dim WDDoc As Word.Document
Dim WDApp As Object
Dim WDDoc As Object
Dim myDocName As String
Dim myPWD As String
Dim WordWasRunning As Boolean
Dim testStr As String

myDocName = "C:\my documents\word\doc10.doc"
myPWD = "mypassword"

testStr = ""
On Error Resume Next
testStr = Dir(myDocName)
On Error GoTo 0
If testStr = "" Then
MsgBox "Word file not found!"
Exit Sub
End If

WordWasRunning = True
On Error Resume Next
Set WDApp = GetObject(, "Word.Application")
If Err.Number < 0 Then
Set WDApp = CreateObject("Word.Application")
WordWasRunning = False
End If

WDApp.Visible = True 'at least for testing!

Set WDDoc = WDApp.documents.Open(Filename:=myDocName)

WDDoc.WritePassword = myPWD
WDDoc.Close savechanges:=True

If WordWasRunning Then
'leave it running
Else
WDApp.Quit
End If

Set WDDoc = Nothing
Set WDApp = Nothing

End Sub

Using the reference is very nice for testing purposes--you'll see the
intellisense. But lots of times, it causes heartache and pain when you
distribute it to others and they have a different version of excel.

Then the slightly slower late binding (As Object) is much safer.

dimm wrote:

Hi all,

I'm trying to open Microsoft Word using VBA. When I execute my code
something processes for a second but nothing happens......I have ticked the
'Microsoft Word 10.0 Object Library' box in the ToolsReferances menu. And I
have the following code:

Sub StartWord()
Dim wrdApp As Word.Application
Set wrdApp = New Word.Application
End Sub

Any ideas are appreciated....


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Start MS Word?

Try adding -

wrdApp.Visible = True

Regards,
Peter T

"dimm" wrote in message
...
Hi all,

I'm trying to open Microsoft Word using VBA. When I execute my code
something processes for a second but nothing happens......I have ticked

the
'Microsoft Word 10.0 Object Library' box in the ToolsReferances menu. And

I
have the following code:

Sub StartWord()
Dim wrdApp As Word.Application
Set wrdApp = New Word.Application
End Sub

Any ideas are appreciated....



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Start MS Word?

Thanks folks, thats great, really great. They all worked a treat. :-) Thankyou.

I started another post now asking how to copy data values (Not the
functions) from excel cells into my now open MS Word document. Any ideas are
appreciated?
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
MS Word and MS Excel won't open from the START menu. OHL101 Excel Discussion (Misc queries) 2 August 24th 09 08:52 PM
Insert the same word at the start of a column of cells Ann Excel Discussion (Misc queries) 3 June 5th 09 11:35 PM
Using Excel to start a merge session in Word luthor Excel Programming 0 April 20th 06 09:26 AM
How to start every word in a cell uppercase? terrya64 Excel Discussion (Misc queries) 1 July 25th 05 02:03 AM
VBA equivalent vbscript start outlook & word Max Bialystock Excel Programming 2 February 29th 04 08:41 AM


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