Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
MS Word and MS Excel won't open from the START menu. | Excel Discussion (Misc queries) | |||
Insert the same word at the start of a column of cells | Excel Discussion (Misc queries) | |||
Using Excel to start a merge session in Word | Excel Programming | |||
How to start every word in a cell uppercase? | Excel Discussion (Misc queries) | |||
VBA equivalent vbscript start outlook & word | Excel Programming |