Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2014, 06:48 AM
ksigcajun ksigcajun is offline What's wrong with my code? Windows 7 64bit What's wrong with my code? Office 2010 64bit
Advanced Beginner
What's wrong with my code?
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default What's wrong with my code?

My code seems to run perfectly in updating all links in my document that I run off my desktop. It takes about 10 seconds to run. When I email the form out to a user, the code takes a few minutes to run and seems to be looping. Why is that? Am I doing something wrong?

Code:
Private Sub CommandButton1_Click()
        Dim myRange     
    Set myRange = Selection.Range     
    Selection.WholeStory
    Selection.Fields.Update     
    myRange.Select    
End Sub
Thanks!
Reply With Quote
  #2  
Old 05-15-2014, 10:22 AM
jpb103's Avatar
jpb103 jpb103 is offline What's wrong with my code? Windows 7 64bit What's wrong with my code? Office 2007
Advanced Beginner
 
Join Date: May 2014
Location: Thunder Bay, Ontario
Posts: 58
jpb103 is on a distinguished road
Default

Are you emailing out the form as a docm? CommandButton1_Click() is a fairly generic name for a macro. If the user already has a macro by that name defined on their system, it's likely they are running that macro instead of the one you sent them.
Reply With Quote
  #3  
Old 05-15-2014, 04:45 PM
macropod's Avatar
macropod macropod is offline What's wrong with my code? Windows 7 32bit What's wrong with my code? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

There are no loops in the code, so the idea that it's looping is mistaken. However, you also mention updating links. Link update performance can be seriously affected by whether the updates are being done over a network. And, of course, if the path to the data is different on the user's PC, Word quite possibly won't be able to find the source find to do the updates from.

FWIW, the macro could be made much more efficient:
Code:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
With Activedocument
  .Fields.Update
  .PrintPreview
  .ClosePrintPreview
End With
Application.ScreenUpdating = True
End Sub
There is no need to select anything.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 05-19-2014, 06:42 AM
ksigcajun ksigcajun is offline What's wrong with my code? Windows 7 64bit What's wrong with my code? Office 2010 64bit
Advanced Beginner
What's wrong with my code?
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default

Thanks for the help everyone. I'm slowly learning all of this in great part of everyone's input.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrong hyphenation NobodysPerfect Word 1 02-04-2014 05:46 AM
What's wrong with my code? Open With (Boy I did something wrong) lostsoul62 Word 1 12-27-2011 07:29 PM
What's wrong with my code? Demo gone wrong RyanNIF Publisher 1 10-19-2011 05:55 AM
column break what am I doing wrong? oaty Word 0 08-12-2010 10:15 AM
What's wrong with my code? PLEASE HELP-wrong formatting???? bruce Word 10 04-10-2010 03:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:03 AM.


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