berty2000
Board Regular
- Joined
- Mar 29, 2011
- Messages
- 71
running Excel 2003 Word 2003
Got a button in excel cell that opens up a document in word and then brings up the print document option automatically.
My problem is if they click Cancel I get an error, Im sure the way i've coded it is not quite right but im trying to teach myself from scraps of code etc
Trying to get my head around the error handler bit but just get confused
This is my VB in Excel
Private Sub CommandButton2_Click()
Set WordObj = CreateObject("Word.Application")
'location of file
WordObj.Documents.Open ("C:\Home\Bill Payment.doc")
WordObj.Visible = True
Set WordObj = Nothing
End Sub
Then I added this VB in the Word Document
Private Sub Document_Open()
Application.Dialogs(wdDialogFilePrint).Show
On Error Resume Next
wrddoc.Close
wrdApp.Quit
End Sub
Anyone willing to help a newbie
Got a button in excel cell that opens up a document in word and then brings up the print document option automatically.
My problem is if they click Cancel I get an error, Im sure the way i've coded it is not quite right but im trying to teach myself from scraps of code etc
Trying to get my head around the error handler bit but just get confused
This is my VB in Excel
Private Sub CommandButton2_Click()
Set WordObj = CreateObject("Word.Application")
'location of file
WordObj.Documents.Open ("C:\Home\Bill Payment.doc")
WordObj.Visible = True
Set WordObj = Nothing
End Sub
Then I added this VB in the Word Document
Private Sub Document_Open()
Application.Dialogs(wdDialogFilePrint).Show
On Error Resume Next
wrddoc.Close
wrdApp.Quit
End Sub
Anyone willing to help a newbie