Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 09-21-2014, 02:30 AM
macropod's Avatar
macropod macropod is offline VBA Code in a UserForm module to delete a Command Button which opens the userform Windows 7 64bit VBA Code in a UserForm module to delete a Command Button which opens the userform Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Is there a reason for having the command button (presumably an ActiveX button) and not starting the userform automatically instead? The code you'd use for deleting the command button would be something like:
ThisDocument.CommandButton1.Delete
but you'll have problems deleting the command button while it's running a macro - which it continues to do until you unload your userform. Alternatively, have you considered using a MACROBUTTON field to start your userform instead of the command button? Such a field might be coded as:
{MACROBUTTON UserformLoad Click Here}
and
Drive a UserformLoad macro coded as:
Code:
Sub UserformLoad()
ActiveDocument.Fields(1).Result.Delete
UserForm1.Show
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command button to show userform suddenly stopped working jpb103 Word VBA 0 05-22-2014 06:05 AM
VBA Code in a UserForm module to delete a Command Button which opens the userform UserForm Search, delete issues johndough Excel Programming 3 05-11-2014 11:44 AM
VBA Code in a UserForm module to delete a Command Button which opens the userform Is it possible to take an input from a UserForm in one document to a UserForm in a do BoringDavid Word VBA 5 05-09-2014 09:08 AM
Userform Code not quite right - help please vbanovice Word VBA 1 09-29-2013 09:20 PM
Word doc bug when closing from userform command button click macro Joe Patrick Word 1 07-05-2011 08:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:48 AM.


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