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

On Feb 21, 12:10*am, Mike H wrote:
Hi,

You weren't seeing an error because your error handler was doing what you
told it to do and handling the error

Sub Write_to_Word()
Dim objApp As Object
On Error Resume Next
Set objApp = GetObject(, "Word.Application")

If Err.Number < 0 Then
* * On Error GoTo ErrHandler
* * Set objApp = CreateObject("Word.Application")
Else
* * 'Bound to instance, activate error handling
* * On Error GoTo ErrHandler
End If
With objApp
* * * * .Visible = True
* * * * .Documents.Add
* * * * .Selection.Font.Name = "Arial"
* * * * .Selection.TypeText "Hello"
* * * * .Selection.TypeParagraph
* * * * .Selection.TypeText Text:="Hello 2"
* * End With
Set objApp = Nothing
Exit Sub
ErrHandler:
'Release the object and resume normal error handling
Set objApp = Nothing
On Error GoTo 0 'Display standard run time error message box
End Sub
--
Mike



Thanks very much Mike - it works beautifully !!!

AP
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
Write text to a table in Word John Excel Programming 1 June 12th 09 01:59 PM
Write in word OLE object Jolene Excel Programming 0 May 6th 09 02:34 PM
HOW PUT WORD-ART IN THE BACKGROUND AND WRITE OVER IT Militza Excel Worksheet Functions 1 August 25th 08 06:52 PM
write to word RobcPettit[_2_] Excel Programming 2 June 6th 07 06:03 PM
How to write in Word w/o Reference Gérard Ducouret Excel Programming 4 April 7th 06 03:04 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"