T
tdk
Guys
I've been trying to write some code that works on on Office
2000,2003,2007 that detects if there is an active document that can be
printed. My first idea was this...
Private Sub PrintIfDocumentOpen()
On Error GoTo ErrorHandler
Dim obj As Object
obj = oXL.ActiveDocument ' force an error if no doc to print
' code here where document exists omiited
Exit Sub
ErrorHandler:
If Err.Number = 4248 Then
MsgBox "There is no document open to print"
Else
MsgBox "Another error occured." & Err.Number
End If
End Sub
This works fine on office 2000 but on Word 2007 I always get an error
70 at the line obj=oXL.ActiveDocument.
I'm not very sure if you can open word with no active document in
Word2007 anyway. If someone coudl confirm this is the case then I can
use my code but first check to see if we ar running in Word2007. I
would have thought there is an easy way to accomplish this but as yet
I did not find it.
Any help much appreciated.
Ps. My COM addin is written in VB
I've been trying to write some code that works on on Office
2000,2003,2007 that detects if there is an active document that can be
printed. My first idea was this...
Private Sub PrintIfDocumentOpen()
On Error GoTo ErrorHandler
Dim obj As Object
obj = oXL.ActiveDocument ' force an error if no doc to print
' code here where document exists omiited
Exit Sub
ErrorHandler:
If Err.Number = 4248 Then
MsgBox "There is no document open to print"
Else
MsgBox "Another error occured." & Err.Number
End If
End Sub
This works fine on office 2000 but on Word 2007 I always get an error
70 at the line obj=oXL.ActiveDocument.
I'm not very sure if you can open word with no active document in
Word2007 anyway. If someone coudl confirm this is the case then I can
use my code but first check to see if we ar running in Word2007. I
would have thought there is an easy way to accomplish this but as yet
I did not find it.
Any help much appreciated.
Ps. My COM addin is written in VB