![]() |
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.... |
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.... |
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 |
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.... |
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? |
All times are GMT +1. The time now is 09:05 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com