web 2.0


Word 2007 random text

The other day I had to teach a Word course and I normally take a text with me so that people can replicate what is being taught. This time, however, I decided to use an old trick from Word whereby you can use the =rand() function to get the following:

On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document. You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks. When you create pictures, charts, or diagrams, they also coordinate with your current document look.

You can easily change the formatting of selected text in the document text by choosing a look for the selected text from the Quick Styles gallery on the Home tab. You can also format text directly by using the other controls on the Home tab. Most controls offer a choice of using the look from the current theme or using a format that you specify directly.

To change the overall look of your document, choose new Theme elements on the Page Layout tab. To change the looks available in the Quick Style gallery, use the Change Current Quick Style Set command. Both the Themes gallery and the Quick Styles gallery provide reset commands so that you can always restore the look of your document to the original contained in your current template.


Besides the traditional =rand() function, we can also use the =lorem() function to return the ubiquitous "Lorem ipsum..." text:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.

Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.


In both cases we get a set of three paragraphs, but you can change that by adding arguments to the functions. If you type =lorem(6) you will get six paragraphs whereas if you type =lorem(3,6) you will get three paragraphs with six sentences each.

========
PS: You can also use this in other Office applications such as PowerPoint. Enjoy!

Tags: , ,

Microsoft Word

How to: VBA email validation

This is a follow up to my post on sending email messages using Windows Vista. You can read the previous post here: http://www.msofficegurus.com/post/How-to-Windows-Vista-SMTP-Server-Using-CDOMessage.aspx

In this post, I discuss email validation using VBA. VBA email validation is a very simple process that does not require much, but you will need to install the Microsoft VBScript Regular Expressions 5.5.

In order to install the reference, follow these steps:

1. Open VBE (Alt+F11)
2. Go to “Tools -->
References…”
3. Search in the reference list for Microsoft VBScript Regular Expressions 5.5, select it and click OK to continue.

The figure below shows the reference installed:


Figure 1: Microsoft VBScript Regular Expressions 5.5 reference installed

NOTE:

                 

Only today, after receiving a comment on this post, I noticed that I was using Excel in Portuguese and not English. Since I am always changing the language settings, I sometimes forget to change back to the language I am writing on. I will leave the image as it is, as I am sure everyone can get the picture (if you will forgive me the pun).

Added: July 3rd, 2009


Now, you can create a boolean user-defined function to test an email string to check whether it is a “regular expression”. In my case, I check for the following pattern:

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

There are a number of patterns that you can you and you should be able to find my patterns, especially in sites that teach java or php (check RFC 2822 for info on pattern). You can then borrow one of those patterns and use in your code.

The user-defined function will look like this:

Function ValidateEmail(ByVal sEmail As String) As Boolean
 
    Dim oRegularExpression     As RegExp
 
'   Sets the regular expression object
    Set oRegularExpression = New RegExp

    With oRegularExpression
'   Sets the regular expression pattern
        .Pattern = "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
 
'   Ignores case
        .IgnoreCase = True

'       Test email string
        ValidateEmail = .Test(sEmail)
    End With
   
End Function


You can now test the user-defined function with a simple call:

Sub Test_ValidateEmail()
    MsgBox ValidateEmail("my.email@hotmail.com")
    MsgBox ValidateEmail("your.EMAIL@hotmail,com")
End Sub

Tags: , , , ,

Microsoft Excel - VBA | Microsoft Office - VBA | Vista

Excel 2007: Pulsating (flashing) Office Button

In Office 2007, Microsoft introduced what is widely known as the "Office Button". This is a button that functions in the same way as the old "File" menu, which gives you tools to work with the file such as Save As, Print, etc.

Have you e
ver wondered why the Microsoft Office Button flashes? Or how to make it flash again?

The first thing to know is that the Button flashes for discoverability reasons, that is, it flashes with the implicit and silent message: "Hey, I am here! Click me!". Once you have "discovered" the Office Button, it will stop flashing in all of the Office applications.

Here's a cool trick to get the Office Button to flash again by tweaking the Windows Registry. Have fun!


Tags: , , ,

Microsoft Office | Ribbon

Office 2007: Customizing the Office 2007 Ribbon

I’ve been working with Office and the new User Interface (UI) since the first beta was available to me. There is a common complaint about “how difficult” it is to get around the Ribbon, that it is less productive, that you need more clicks to get to a command, yadayadayada.

Is the Ribbon larger? Does it take more screen space? Well, get that measuring tape out of your toolbox and measure it by yourself and be surprised after comparing it to the old toolbars. Are the commands more difficult to find? Have a go in creating and modifying a chart and let me know.

I don’t have the statistics for all those who complain about the new UI, but from those who I have heard the complaints they all have one thing in common: they have used Office for a loooooooong time and had way too many customizations for which they will die before giving them up. As for the average user, it probably does not matter that much as they were using a fraction of Office resources and had little customizations of their own (I am saying this one without the stats to back it up, just guesswork).

But I am a guy who loves change. I see change as challenge, except for the middle part (“lle”), and the new UI represents just that: a challenge. And challenges are opportunities. It keeps us on the ball, active, and shrugs off any possible brain rheumatism we may be prone to.

This is how the RibbonX book came to life and I am happy we have had good feedback on it. It is a pity we left out Visual Studio, but at the time we thought it was not mature enough to justify a chapter on it. After VS 2008, I am convinced things will have changed drastically for the better and, the publishers willing; we will have a second edition which will be much richer in content.

If you have any queries or want to discuss things further, drop me a line.

As Teresa would say: life is full of opportunities, celebrate them all!

Tags: , , ,

Microsoft Office | Ribbon