![]() |
|
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
![]()
Sometimes one needs to replicate/transform/move some object big number of times uniformly, usually you just press and hold Ctrl-R then after some time release, select what you got and so you see how many objects there are...;-) hehe
This simple macro asks number of repeations and does Ctrl-R for you precisely number of times specified with progress indicator. Code:
Sub repeatLast() dim stat As AppStatus, i as long, reps as long On Error Resume Next reps = Abs(Int(CDbl(InputBox("repeat last command number of times:", "Auto repeater", "2")))) Set stat = Application.Status: stat.BeginProgress CanAbort:=True If reps = 0 Then Beep: Exit Sub For i = 1 To reps ActiveDocument.repeat stat.Progress = i / reps * 100 stat.SetProgressMessage "Repeating..." & Str(i) & " / " & Str(reps) If stat.Aborted Then MsgBox "Command repeated " & Str(i) & " out of " & str(reps) & " times": Exit For Next End Sub I assigned this macro to CtrlShiftR. I'm really happy;-))) |
#2
|
|||
|
|||
![]()
Hi! Here is the answer how to make onestep undo any macro (it's also speed up the execution with turn off what may and create an minimal errorhandling...):
Code:
Sub AnyWhatYouWant() Const MakroTitle as String = "Here is your makro name's place" Dim ErrorCode As ErrObject ' First rutins to check if any document is open ' and have other stuff to do what you want... Speeder True, MakroTitle On Error GoTo ERRORHANDLING ' Place of your code: exit with GoTo ERRORHANDLING ' or enabling Speeder disabled features any other way... ' End of the execution ERRORHANDLING: ErrorCode = Err On Error GoTo 0 Speeder false if ErrorCode <> 0 then Err.Raise ErrorCode End Sub '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Public Sub Speeder(State As Boolean, Optional UndoTitle As String = "Makro execution") If State Then ActiveDocument.BeginCommandGroup UndoTitle Optimization = True EventsEnabled = False ActiveDocument.SaveSettings "Speeder" ActiveDocument.PreserveSelection = False Else ActiveDocument.RestoreSettings "Speeder" EventsEnabled = True Optimization = False Refresh ActiveDocument.EndCommandGroup End If End Sub Last edited by petig; 03-09-2005 at 20:39. |
#3
|
||||
|
||||
![]()
to petig: I use similar procs, but if I call begincommandgroup, then activedocument.repeat won't repeat previous command, I tried in my macro, no way.
|
#4
|
|||
|
|||
![]()
Oh, yes! Exuse me, it was late night when I read your post, I didn't understand well your last sentence. You're right, no way...
Last edited by petig; 04-09-2005 at 12:11. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
New macro to clip curves w.r.t. a border | Gerard Hermans | Macros/Add-ons | 0 | 09-06-2003 07:50 |