error handling for newbie

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 :)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,224,531
Messages
6,179,384
Members
452,908
Latest member
MTDelphis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top