View Single Post
 
Old 07-05-2011, 06:48 PM
Joe Patrick Joe Patrick is offline Windows 7 64bit Office 2007
Advanced Beginner
 
Join Date: May 2011
Posts: 33
Joe Patrick is on a distinguished road
Default Word doc bug when closing from userform command button click macro

Hi,

This macro works closes the document fine except when initiated from a command button on a userform. Can someone help me figure out why and what I need to do to get it to work, please?

Macro:
Sub CloseDontSave()
Word.ActiveDocument.Close wdDoNotSaveChanges
End Sub

I have a command button on the doc that runs it and that's fine. I've created an AutoClose macro to show a userform if the user does not click any of the buttons provided. One of the buttons on the userform is also set to run this macro but bugs out when closing the doc.

Private Sub CommandButton3_Click()
UserForm2.Hide
Application.Run MacroName:="CloseDontSave"
End Sub

This is the error I get:
Run-time error '-2147352567 (80020009)':
Method 'Run' of object '_Application' failed
Reply With Quote