Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-05-2011, 06:48 PM
Joe Patrick Joe Patrick is offline Word doc bug when closing from userform command button click macro Windows 7 64bit Word doc bug when closing from userform command button click macro Office 2007
Advanced Beginner
Word doc bug when closing from userform command button click macro
 
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
  #2  
Old 07-05-2011, 08:53 PM
Joe Patrick Joe Patrick is offline Word doc bug when closing from userform command button click macro Windows 7 64bit Word doc bug when closing from userform command button click macro Office 2007
Advanced Beginner
Word doc bug when closing from userform command button click macro
 
Join Date: May 2011
Posts: 33
Joe Patrick is on a distinguished road
Default

Ugh, never mind, that was dumb. It's bugging out on close because it was already in the process of closing.

I changed the macro to this and it's good to go:

Sub CloseDontSave()
ActiveDocument.Saved = True
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word doc bug when closing from userform command button click macro Launch macro sub after hitting "create pdf" button in word webharvest Word VBA 1 06-29-2011 04:56 PM
Word doc bug when closing from userform command button click macro Right click in Macro MShroff Word VBA 4 04-05-2011 09:00 PM
Word doc bug when closing from userform command button click macro Command Button cksm4 Word VBA 7 02-27-2011 08:47 PM
Button click event from a noob jsampson Outlook 0 10-12-2010 01:48 PM
Add-In:How to add command right click command bar phang Outlook 0 01-15-2007 02:53 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft