S
Stan Mulder
What is wronge with this code intended to copy from an Excel worksheet to a
closed word document (with a formatted header)?
Thanks in advance !
Dim objWord As Object
On Error GoTo failed
'1st call without 1st argument returns reference to an instance of the _
application, and causes error(429) if .doc is not open.
Set objWord = GetObject("F:\LSD_050206\calcsht.doc")
failed:
If Err.Number = 429 Then
'2nd call specifies a file to open, starts it, returns ref. to existing
_
document & makes doc. visible
Set objWord = GetObject("F:\LSD_050206\calcsht.doc", Word.Application)
End If
Worksheets("Beam").Activate
With ActiveSheet
Worksheets("Beam").Range("A1: T55").Copy
End With
'release the reference
Set objWord = Nothing
closed word document (with a formatted header)?
Thanks in advance !
Dim objWord As Object
On Error GoTo failed
'1st call without 1st argument returns reference to an instance of the _
application, and causes error(429) if .doc is not open.
Set objWord = GetObject("F:\LSD_050206\calcsht.doc")
failed:
If Err.Number = 429 Then
'2nd call specifies a file to open, starts it, returns ref. to existing
_
document & makes doc. visible
Set objWord = GetObject("F:\LSD_050206\calcsht.doc", Word.Application)
End If
Worksheets("Beam").Activate
With ActiveSheet
Worksheets("Beam").Range("A1: T55").Copy
End With
'release the reference
Set objWord = Nothing