POWER OF MACROS : | FAQ
 
Welcome, Guest. Please login or register.

username, password for forums login
search for : Google Custom Search
home windows linux mac os x software how-to features tech & tests downloads videos forums blogs mail
all techs & tests      

print tech Friendly print

Power of Macros

Macros are very powerful tool for work, and if you are not familiar with them you are missing great opportunity to speed up most of your work, especially if you are working with tables, text formatting and even with drawing. With this SoftwareTipsPalace.com post in out Tech & Tests section we will try to help you to understand much better this great tool which is available in most of software’s like Word, Excel, CorelDRAW, etc…

Jul 16, 2007 18:21 PM

-----------------------------------------------------------------------------------------------------------

Most of software users do have possibility to work with macros, scripts, actions etc... In basic description it's possibility of applications to remember group of your moves and to repeat those move as much as you want. Primarily ideas on using of Macros were to make any work easier and to make shorter all repeating operations. We will start with example inside macrosoft Word (which of course have possibility to work with Macros). Let us say that you have some text from your friend with more tithe of tables which do not look like same trough whole text or simply don't like you want. To edit all these tables using macros do next:

  1. Open your text with MS Word
  2. Mark first table,
  3. then choose  option "Tables --> Macros Record new Macro",
  4. Give the name to macro which you just created and start with table formatting (table weight, line weight, font style etc.)
  5. After you finish with table formatting click "Tools --> Macros --> Stop Recording" to end macro recording,
  6. Next time when you select any table inside this document you can setup same values by calling previous save macro (Tools --> Macros --> Macros --> choose macro and click Run)
  7. You can also add shortcut for this macro and with one click you can fix every table inside this document.

To see how Macro is written, choose "Tools --> Macros "STPTable" --> Edit" where "STPTable" represent macro name:

Sub FixSTPTable ()
    With Selection.Cells(1)
      .LeftPadding = MillimetersToPoints(1)
      .RightPadding = MillimetersToPoints(1)
      .VerticalAlignment = wdCellAlignVerticalCenter
      .WordWrap = Tru
      .FitText = False
    End With
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.Tables(1) .PreferreWidthType = wdPreferreWidthPoints
    Selection.Tables(1) .PreferreWidt = MillimetersToPoints(112)
    Selection.Font.Name = "Arial"
    Selection.Font.Size = 8
    With Selection.Tables(1)
     With .Bords (wdBorderHorizontal)
       .LineStyle = wdLineStyleSingle
       .LineWidth = wdLineWidth075pt
       .Color = wdColorBlack
     End With
     With .Borders (wdBorderVertical)
      .LineStyle = wdLineStyleSingle
      .LineWidth = wdLineWidth075pt
      .Color = wdColorBlack
     End Withn
    End With
    Selection.Rows.AllowBreakAcrossPages = True
End Sub

Even if you never did met with something similar, it will be evidence to you that macros are simple writhed options and their parameters.

Unfortunately, there are some limits on macros using. When you call saved macro, he will literally repeat all steps which you saved for a first time. If you change any parameter condition, macros which you are calling will not do his job and he will report on error. One more limitation on using of macros is that programs can’t record all your moves which you are making with your mouse.

Small macro Modifications

Next example is “text cleaner” and it is function “Replace”, function which we here in SoftwareTipsPalace.com using for small cleaning of “dirty” text. You will see that with small modifications of saved macro you can very easily add new macro possibility. Also the process of macro saving will be shorter with all set of functions compared with previous example.

If you save your macro like one text replacement “aaa” into “bbb” using function “Edit:Replace” and look how it looks like (Tools --> macro --> Macros --> choose macro --> Edit) it will look like example below :

Sub Macro1 ()
Selection.Find.ClearFormating
Selection.Find.Replecement. ClearFormating
With Selection.Find
  .Text = “aaa”
  .Replecement.Text = “bbb”
.Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
 End With
 Selection.Find.Execute Replace:=wdReplaceAll
End Sub

We will change macro so the function call Replace will apply on whole content of active document and not only on selection and instead one “Execute” we will add whole series of them, with different values for marks which we are changing and marks which we are using to change them. Look example below:

Sub TextReader ()
  With ActiveDocument.Content.Find
    .ClearFormating
    .Replacement.ClearFormating
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWholecards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll, Findtext:=”<<”, Replacewith:=Chr (34)
    .Execute Replace:=wdReplaceAll, Findtext:=”>>”, Replacewith:=Chr (34)
    .Execute Replace:=wdReplaceAll, Findtext:=”,,”, Replacewith:=Chr (34)
    .Execute Replace:=wdReplaceAll, Findtext:=”””, Replacewith:=Chr (34)
    .Execute Replace:=wdReplaceAll, Findtext:=”””, Replacewith:=Chr (34)
    .Execute Replace:=wdReplaceAll, Findtext:=”^p”, Replacewith:=”^p”
    .Execute Replace:=wdReplaceAll, Findtext:=” ^p”, Replacewith:=”^p”
    .Execute Replace:=wdReplaceAll, Findtext:=”^p^t”, Replacewith:=”^p”
    .Execute Replace:=wdReplaceAll, Findtext:=”  ”, Replacewith:=”  ”
  End With
End Sub

This macro is equivalent to process in which we with more “Replace” commands replaced different quotation marks into normal quotation marks, remove blank space from end of text and beginning of paragraph, and also changed double space into one space.

Small macros programming

By modifying macros (now we need to use programming techniques) we are accomplish to important goals:

  • Possibility to use much more additional functions which are don’t exist in programs menus,
  • Making our macros a little bit smarter (now our macros are becoming small programs)

Now, using these new techniques you could add few additional checking’s in our previous example with tables, and we will be sure that macro will work only if he accomplishes certain prerequisite. You can also add that macro selected table if she is not selected (because we hope that you remember that in our first macro example we didn’t choose Table --> Select --> Table).

Most important is that using programming you can have much more options and modifications for your macro and you can save a lot of time in work.

Use Macros in painting

We did talk enough about Word, lets us say few word about CorelDRAW, which also have possibility to work with macros, and he can also work with VBA. Using saved macro you can repeat whole series of same transformations for more than one graphics objects. But the real power of macros is in programming. Here one example:

Sub STPColors()
  Dim s(10, 10) As Shape
  ActiveDocument.Unit = cdrMillimeter
  ActiveDocument.ReferencePoint = cdrBottomLeft
  With ActiveLayer
    For i = 1 To 10
      For j = 1 To 10
        Set s(i, j) = .CreateRectangle2(i * 10, j * 10, 10, 10)
        s(i, j) .FillUniformColor.CMYKAssign i * 10, j * 10, 0, 0
        s(i, j) .Outline.Type = cdrNoOutline
      Next j
    Next i
  End With
End Sub

In bottom left corner of CorelDRAW document this macro will draw 10x10 square grids with size of 10x10 mm; this square will also have background color with arithmetic color values.

 

Bookmark del.icio.us digg power of macros Digg this! Share on Facebook

<< Back to Techs & Tests
Progress of computer Technology's >>


 


advertisement

  More Macros Tips
Using Macros in MS Word and Excel
Given that computers are supposed to save time and make life easier, it can seem as if we spend a lot of our computer time doing the same tasks over and over again, whether it's signing off a letter, changing the formatting of a Word document or sorting cells in a spreadsheet. The solution is to get your computer to perform a set of tasks automatically when you enter a prompt, which you can do by creating a macro. Macros help make your computer work the way you want it to and can be great time savers. The best news of all is that they are easy to set up using tools built into Office programs such as Word and Excel, as well as other software ...
 


  MS Word Tips and Tricks
Maintain you Blog with Microsoft Word 2007
Do you have your own Blog and you are tired with his old look? You can try to use Microsoft Word 2007 to change look of you Blog. It is very easy to publish or redesign your favorite Blog to your Blog site using Microsoft’s Word 2007. Using Word 2007, you can literally save tons of time to post a new blog entry or modify an existing blog entry ...
Using Word’s Style area feature
Change a Word field into static text
Insert Calculator in MS Word 2003
Sorting Text in Word 2003
MS Word Tips and Tricks
 

  MS Excel Tips & Tricks
Euro character is represented as perpendicular line
Filling a Range with a Series of Dates
Dividing a First Left Heading Title
Changing the Indentation in a Cell
Finding/Finding & Replacing in a Single Sheet or in All Sheets
Excel Tips & Tricks
 

advertisement
Dell Home Systems

  Latest News and Techs Discusses on Forums
xx So silence here
March 30, 2010, 11:06:31 AM by rislyy
I find it is so silence here.  Why?
1 comment | Write Comment

xx Battle of DVD Rippers: Easy VS Fast
January 27, 2010, 09:37:43 AM by aqqqa222
Are you searching for DVD converters to backup your great DVDs into your PC or enjoy DVDs on your...
0 comments | Write Comment

xx Get free Acronis True Image 8.0 and convert it to Acronis True Image 2009!
October 25, 2008, 09:52:45 AM by lisja4ij
Recently I came across an article on Windowssecrets. com (hxxp: windowssecrets....
0 comments | Write Comment

thumbup How to optimize your computer performances with 2 hard drives?
January 30, 2008, 10:53:43 AM by onesimus
I very much like this tip,but I would like it if the how to would be...
1 comment | Write Comment
 
search web for : Google Custom Search
home | forums | blog | web mail | windows | mac | linux | software spotlight | how-to features | techs & tests | web 2.0 reviews
Power of Macros at SoftwareTipsPalace.com
About Us | Privacy Policy | Terms of Use | Advertising Info | Contacts | FAQ's | SiteMap   Software Tips and tricks rss
Copyright © 2008 SoftwareTipsPalace.com. All rights reserved.