Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-01-2017, 08:11 AM
StephenRay StephenRay is offline Consolidate 25 Macros Into One, Too Many Hot Keys! Windows 7 64bit Consolidate 25 Macros Into One, Too Many Hot Keys! Office 2010 64bit
Advanced Beginner
Consolidate 25 Macros Into One, Too Many Hot Keys!
 
Join Date: Jan 2012
Location: Overland Park, Kansas
Posts: 53
StephenRay is on a distinguished road
Default Consolidate 25 Macros Into One, Too Many Hot Keys!

If it is possible, I want to learn to consolidate about 25 Macros that I presently run by 25 different Hot Keys. I have all the Hot Keys memorized. I usually run these in a certain order but sometimes I go back and run one out of the usual sequence.
I envision one consolidated Macro where …once it is started, Macro1 would run displaying a Message box, …Then when a Hot Key, (or the Enter Key), is depressed, Macro2 would run, displaying a Message Box, …Then that same Hot Key, depressed again, it would cause Macro3 to run displaying another Message box, …and so on through the 25 Macros. A button in the Message box would be convenient to do the same thing as that same hot key.
I also envision during this process that if one of the original 25 different Hot Keys, is depressed, it would cause the sequence to go out order, directly to the Macro associated with that unique Hot Key whereupon a Message Box would appear; -and where the sequence/loop would then start from that place!
The Message Box would show the operator something like:
“Name is on the clipboard: Joe Jones.” Or
“Address is on the clipboard: 811 Walnut Street.”
I don’t really need the message box, I am thinking the appearance of a Message Box is the only way to pause, is that right? Presently, each separate Macro highlights the text on the clipboard in the Active document so I can glance at it to be sure I have grabbed the right thing to the clipboard.
These 25 macros are usually simple, finding text and combining complicated texts in a Microsoft Word Document and highlighting a name or address or other text, putting it on the clipboard, ready to be pasted to another application, Microsoft Active Directory, on another screen while I am using dual screens.
A couple of these Macros open another document, find some text based on what is already on the clipboard, -then highlights and gets different text on the clipboard, then closes that document, making the original document the active document. The last Macro in the sequences does a Save AS, Closes the Active Document, changes the directory, and opens a document ready for the cycle to begin again.
What say you? Is it possible to combine my 25 Macros into one big Macro and traverse through it sequentially or go to a certain part of it?
Here’s an example of one of these Macros, a very simple one that gets the name to the clipboard:


Sub Macro17()
' Macro17 Macro
'Name
'This part clears the clipboard
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText ""
clipboard.PutInClipboard
Dim oRng As Range
‘The name is always on the second line
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
‘This next part gets the spaces out
Set oRng = Selection.Range
oRng.Text = Trim(oRng.Text)
oRng.Copy
ActiveDocument.Undo 1 'Put the spaces back in the text.
'Highlights the text so the operator can see what is on the clipboard
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Consolidate 25 Macros Into One, Too Many Hot Keys! Macros to move objects prevents moving same objects with arrow keys BruceM Word VBA 1 03-10-2015 08:20 AM
Consolidate Pivots linked to SQL mtayloripf Excel 0 02-11-2014 08:16 AM
Consolidate 25 Macros Into One, Too Many Hot Keys! How Find Out What Keys Trigger My Macros? peytontodd Word 1 10-28-2013 09:39 AM
Consolidate 25 Macros Into One, Too Many Hot Keys! Consolidate names jgross30 Excel 7 05-13-2013 08:36 PM
Is it possible to bind macros to keys not in the KeyCodeConstants class? AlexR Word VBA 4 04-08-2013 10:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:25 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