Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 06-24-2015, 02:59 PM
macropod's Avatar
macropod macropod is offline Executing a userform with a command button Windows 7 64bit Executing a userform with a command button Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

Without knowing what you want to execute, it's impossible to give any advice. However, unloading the form as your post indicates before executing its code is liable to result in the code not being executed.

Also, you don't need to change folders via ChangeFileOpenDirectory. You can open the file explicitly. Nor do you need to copy & paste. Try, for example:
Code:
Sub CheckBox1_Click()
Dim DocSrc As Document, DocTgt As Document
Const StrFld As String = "X:\sconner\CCD Damage Mechanisms\Data Transfer Practice\"
Set DocTgt = ActiveDocument
Set DocSrc = Documents.Open(FileName:=StrFld & "Mechanism Transfer Practice.docx", _
  ReadOnly:=False, AddToRecentFiles:=False)
DocTgt.Range.FormattedText = DocSrc.Range.FormattedText
DocSrc.Close
Unload Me
End Sub
PS: When posting code, please use the code tags, inserted via the # button on the posting menu.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
command button, macros, userforms



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a Command Button dkohnken Word VBA 5 03-18-2015 10:13 PM
VBA Code in a UserForm module to delete a Command Button which opens the userform Simoninparis Word VBA 2 09-21-2014 03:50 AM
Command button to show userform suddenly stopped working jpb103 Word VBA 0 05-22-2014 06:05 AM
Word doc bug when closing from userform command button click macro Joe Patrick Word 1 07-05-2011 08:53 PM
Executing a userform with a command button Command Button cksm4 Word VBA 7 02-27-2011 08:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:29 PM.


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