Wednesday, December 15, 2010

Filename Field Code in Word

Many times I'll use a field code to insert the filename into the footer of a document. The field code looks like this:

{ FILENAME \*MERGEFORMAT}

The result of the field code looks like this: foobar.doc

The filename has a ".doc" suffix. When I create the PDF, the filename in the footer still has the ".doc" suffix, and not ".pdf".

What I found is that the field code uses the filename exactly as it appears in the Windows Explorer window. This may sound trivial, but to solve the problem we just need to hide the extension in Windows Explorer.

To change the setting follow these steps:
  1. Open Windows Explorer
  2. Click Tools -> Folder Options
  3. Click on the View tab
  4. Check Hide extensions for known file types
Now, after updating the field code, we get foobar instead of foobar.doc.

[Source Wordribbon.Tips.net]

Monday, November 8, 2010

Painting in Irfanview

You learn something everyday. A co-worker asked me if I knew of a program to add circles and arrows to an image. Immediately, I thought "Irfanview must be able to do that". 

Quickly, I opened an image in Irfanview and searched the menus for "Add circle" or "Add arrow" or something like that. Instead I found the menu for "Show Paint Dialog". Bingo.

Click "Edit -> Show Paint Dialog", or type F12 and the MS Paint dialog opens. Now you have the capability of MS Paint from within Irfanview. Add a circle, add an arrow, or whatever you like :)

Thursday, October 28, 2010

En, Em, Eh, What?

There are different types of dashes: hyphen, en dash, and em dash. What is the difference between them?

Hyphen (-): This is the width of one digit. It is used to hyphenate words that break across a new line, or to join compound words. Ex. My, this professor is long-winded.

En Dash (–): This is the width of the letter 'n'. It is used to indicate a range of values. Ex. I will be on vacation from November 6–10.

Em Dash (—): This is the width of the letter 'w'. This is used to indicate a break in thought. Ex. I was eating pizza—and what a good pizza it was—with all my favorite toppings.

Using courier font we can get a better idea of the widths:
0 n m
- – —
[Sources: Fonts.com and Wikipedia]

Tuesday, October 12, 2010

Excel Macro for Background Color


I was writing an Excel Macro and I needed to set the background color of a cell based on the text value. To do this I wanted to use Conditional Formatting, and I found out that you cannot (AFAIK) setup Conditional Formatting from inside of a macro. But, you can create a macro that loops through a range and sets the formatting.

Here is how:
  1. Open the VB editor (Alt + F11)
  2. Open ThisWorkbook under Microsoft Excel Objects
  3. Add the following code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Set myRange = Range("C4:C104")
    For Each Cell In myRange
        If Cell.Value = "n" Then
            Cell.Interior.ColorIndex = 3
        End If
    Next
End Sub

Anytime  a change is made to the workbook, the macro is called. It checks a range of cells, and then if the text is 'n' it sets the background color to 3. But what is '3'?

Thursday, August 19, 2010

Break Types

Different types of breaks may be inserted with the following macro command:

Selection.InsertBreak Type:={type}

where {type} is one of:
  • wdPageBreak
  • wdColumnBreak
  • wdSectionBreakNextPage
  • wdSectionBreakContinuous
  • wdSectionBreakEvenPage
  • wdSectionBreakOddPage
  • wdLineBreak

[Source WordTips]

Sunday, August 15, 2010

Ready, Set, No-Go

You were supposed to leave work 15 minutes ago but you squeezed in some last minute details and now you want to run. So, you save & close your applications, and then click shutdown on your fancy new laptop with Windows 7. You jump up and get ready to run, but then you see the dreadful message:

Do not unplug your machine
Installing update 1 of 15 ....

Now what? You sit and wait 20 minutes while it installs, looking at your watch every minute. Isn't there some way around this? 

Actually there is. Instead of using the Shutdown from the start button, do this:
  1. Type Control-Alt-Delete
  2. In the bottom right corner then is a small power button. Click the arrow
  3. Choose Shutdown
The menu that opens gives you the option to Shutdown with Updates or just Shutdown.

[Source: MyTechGuide]

Monday, August 2, 2010

The Path

Here is a handy shortcut that I just found out about:

Under Windows 7, if you need to copy the path to a file, you just hold the Shift key, then right mouse click on the file. The menu that opens now has a new menu item in the middle called "Copy as path". You can then use Paste to put the full path where ever you like.

Tuesday, June 15, 2010

What is a Lexophile?

1. lexophile - A lover of cryptic words

For those of you who like punny lists:

1. A bicycle can't stand alone; it is two tired.
2. A will is a dead giveaway.
3. Time flies like an arrow; fruit flies like a banana.
4. A backward poet writes inverse.
5. In a democracy it's your vote that counts; in feudalism, it's your Count that votes.
6. A chicken crossing the road: poultry in motion.
7. If you don't pay your exorcist you can get repossessed.
8. With her marriage she got a new name and a dress.
9. Show me a piano falling down a mine shaft and I'll show you A-flat miner.
10. When a clock is hungry it goes back four seconds.

Wednesday, June 2, 2010

Empty Nest(ed) Tables

I had a large document with many, many tables.  I needed to make sure that none of the tables contained any sub-tables.  Macros to the rescue!

Sub removeNestedTables()
'
' removeNestedTables Macro
'
'
    Dim myTable As Table
    Dim subTable As Table
   
    Dim ttCell As Word.Cell
   
    For Each myTable In ActiveDocument.Tables
        For Each ttCell In myTable.Range.Cells
            If ttCell.Tables.Count > 0 Then
                For Each subTable In ttCell.Tables
                    subTable.ConvertToText Separator:=", "
                Next subTable
            End If
        Next ttCell
    Next myTable
End Sub

Sunday, May 30, 2010

The Incredible Shrinking Sentence

The Cannonball Run (1981)
He's my shrink. He was committed yesterday. 

If you have a block of code with long lines that you quote in a document, the long lines can wrap around to the next line which looks really bad and makes the code harder to understand.  To fix this problem, we start with a macro found over at WordTips and add a conditional statement so that it only is executed for a certain style (in this case Code Box). The macro reduces the font by ChangeSize and then checks if the paragraph fits on one line. It then repeats this process until it fits on one line.

Sub forceParaOneLine()
    Dim objPara As Paragraph
    Const ChangeSize = 0.5
   
    For Each objPara In ActiveDocument.Paragraphs
        If objPara.Style = ActiveDocument.Styles("Code Box") Then
            With objPara.Range
                While .Information(
wdFirstCharacterLineNumber) <> .Characters(Len(.Text)).Information(wdFirstCharacterLineNumber)
                    .Font.Size = .Font.Size - ChangeSize
                Wend
            End With
        End If
    Next objPara
               
End Sub

Note that if you have really long lines, this will reduce the font so that it is impossible to read.  To avoid this, I suggest using 2 styles in your document: one for code that can be shrunk, and one that is not shrunk.

[source WordTips]

Wednesday, May 26, 2010

Gmail: Going Label Crazy

Marion: [laughs] What is this stuff, Rene?
Belloq: [laughing as well] I grew up on this. It's my family label.  

This morning I noticed that you can apply custom colors to labels in Gmail. I have used labels in the past, but the labels didn't really stand out which reduced their usefulness.  With custom labels you can easily differentiate all the emails in your Inbox (work emails in one color, mailing list emails in another color, etc.)

Here's how to use the custom colors. First, create labels and filers.
  1. Create a label. See instructions from Google Help.
  2. Create a filter to apply the label. See instructions from Google Help.
Now we need to apply custom colors to the labels. Click the little arrow next to the label that you want to change:

 When you click the arrow, you get a popup window like this one:
The color choices were a little too dark for my taste.  When I tried them, it was hard to see the text next to them because of the contrast.  You can click on Add custom color and choose a background and text color.

Now all your labels look just the way that you want them.

Happy labeling :)

Sunday, May 16, 2010

Selecting a Text Block

I just came across the shortcut of the year for MS Word over at TechRepublic.  Normally, when selecting text, you select it in a continuous line.  You can expand the selection forwards or backwards.

But, did you know that you can select a text block?  This is one of the powerful features of Vim for those of you who have used Unix computers.

Just hold the ALT key while you click.

For example, if I have the following text:

REM First  line
REM Second line
REM Third  line

You can hold the ALT key and then select the first three letters of each sentence:


REM First  line
REM Second line
REM Third  line

You can also cut and paste a block of text. In the above example, one could cut the selection and then paste it in the middle of the first line, resulting in:


 First REM line
 SecondREM line
 Third REM line

Note that selection of text blocks does not work inside of tables.

[Source TechRepublic]

Word: TOC Switches

The Princess Bride (1987)
You only think I guessed wrong! That's what's so funny! I switched glasses when your back was turned! Ha ha! You fool! You fell victim to one of the classic blunders - The most famous of which is "never get involved in a land war in Asia" - but only slightly less well-known is this: "Never go against a Sicilian when death is on the line"! Ha ha ha ha ha ha ha! Ha ha ha ha ha ha ha! Ha ha ha... 

Switches are what you use when building a TOC in Word to make it do what you want it to do. For example, { TOC \c "tables" } will make a TOC based on a sequence field identifier.

Here are some basic field command shortcuts:
  • ALT+F9 show/hide all field codes
  • Shift+F9 show/hide current field code
  • Ctrl+F9 insert an empty field
  • Ctrl+a, then F9 updates all fields in the document
The following lists all the available switches (taken from the Microsoft site, see links at the bottom).

Thursday, May 6, 2010

Too Much Style

Police Officer: You in the red Corvette! Pull over immediately.
Xander Cage: Yeah, yeah. These monkeys are following me because I just took this car. Obviously the car doesn't belong to me, it's not my style...

If you are overwhelmed by the number of styles in Word 2007, you can configure Word to show only the styles that are currently being used in the document:
  1. Alt + Ctrl + Shift + s  (opens the style box)
  2. Click on Options on the bottom right
  3. Under Select styles to show choose In use
Now, in the panel on the right you only see what is currently being used in the document.  The ribbon at the top still gives you access to all the styles.  If you apply a style that is not currently being used, then it gets added to the panel on right.

You can also use Ctrl + Shift + s to pop up a window where you can type in a style name. This window has auto complete, so just start typing and the closest match to the style name will fill in.

Sunday, May 2, 2010

Power to the Point

Have you ever sat through an awful presentation? I think that we all have. Too many slides. Too little time.

"Good morning class.  Today we have to move a little fast.  We've got 1 hour and 60 slides, so no questions until the end."

Or, there's the presenter who crams his whole presentation into the slides.

"Um, excuse me... are you just going to read each slide to me?  It seems like your not adding anything, so can I just have a copy of the slides and I'll go back to work?"

Here is a nice rule of thumb for Powerpoint presentations (from this blog):

It’s quite simple: a PowerPoint presentation should have ten slides, last no more than twenty minutes, and contain no font smaller than thirty points.

Monday, April 19, 2010

Word: Show Me My Property

Word documents have many user-accessible properties, such as Author, Title, etc.  One can find them by clicking on the Word Button -> Prepare -> Properties.  These properties can also be accessed by a macro using the BuiltInDocumentProperties method.

This post will show you which properties are available and how to access them using macros.

Thursday, April 15, 2010

Back From the Future


Lou: You gonna order something, kid?
Marty McFly: Ah, yeah... Give me - Give me a Tab.
Lou: Tab? I can't give you a tab unless you order something.
Marty McFly: All right, give me a Pepsi Free.
Lou: You want a Pepsi, PAL, you're gonna pay for it.  

Here is a simple tip that can save a lot of time. If you click on a link in a PDF file, how to you go back to where you started?

The answer: Alt + Left arrow

Example: If you are on page 2  and you click a link that takes you to page 155, Alt + left arrow takes you back to page 2.

If you want to go back to the future, uh, I mean back to the page that you went to before, then use Alt + Right arrow.

Wednesday, April 14, 2010

Changing Weekend in Excel Workday

If you live somewhere where the weekend is on Friday and Saturday instead of Saturday and Sunday, here is a hack to the Excel Workday function to calculate the correct dates:

WORKDAY(K5+1,5)-1

where K5 holds the date. Just add 1 to the date and subtract 1 from the result.

[source here]

Preventing Emails with Blank Subject Lines in Outlook

Here is a nice fix to prevent Outlook from sending emails without anything in the subject:

Save yourself the annoyance by following the next steps.
  1. Open the Visual Basic Editor (in Outlook, press ALT+F11).
  2. On the left-hand side of the screen, expand the ‘Project1 (go into ‘Microsoft Office Outlook Objects’ -> ‘ThisOutlookSession’).
  3. Double click on ‘ThisOutlookSession’
  4. Paste the following lines of code in the right-hand pane of the screen:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.Subject = "" Then
    Cancel = MsgBox("This message does not have a subject." & vbNewLine & "Do you wish to continue sending anyway?", vbYesNo + vbExclamation, "No Subject") = vbNo
    End If
End Sub

Save the project (‘File’ -> ‘Save’) and return to Outlook. From now on, the code will be called every time you press the send-button after you composed an email. Outlook will pop up a warning when you try sending an email with an empty subject line.

Monday, April 12, 2010

For Example, That Is...

I can never remember if I should use i.e. or e.g., so I am putting it on my blog so that I can find it fast.
  • i.e. means id est in Latin and "that is" in English
  • e.g. means exempli gratia in Latin and “for example” in English

Macros: Moving the Selection

I taught myself how to use macros (through lots of web searching and testing lots of bad code in Word), and therefore, there are some basics that were left out along the way.  Today's post is about one of those missing pieces: moving the selection.
Once something is selected, the selection can be changed by issuing a command with the following parameters:
  1. Move type
  2. Move unit
  3. Count
  4. Extend 

Sunday, April 11, 2010

Super Copyrights

Today I changed a term in one of my documents to use a fancy, new term which has a copyright.  For some reason (which I'll ignore for now) when I replaced the term, the copyright symbol was not put into superscript. So, macros to the rescue:

Sub copyrightToSuperscript()
'
' copyrightToSuperscript Macro
'
' Change all copyright symbols to superscript

Wednesday, April 7, 2010

The Future of Publishing

If you've got an extra 2 minutes and 26 seconds, this video is worth watching.  It is a little boring at the beginning, but watch it the whole way through.



Wednesday, March 24, 2010

More Bathroom Humor



I my office we have one bathroom that has two stalls next to each other.  The stall on the left has a nice big fan which provides plenty of ventilation.  The stall on the right has no ventilation. Now, someone probably complained about the lack of ventilation so they searched long and hard, and consulted with the best bathroom consultants in the country for a solution to the problem.  What was the solution?

All of you brilliant thinkers out there probably came up with the same solution:  Cut a hole in the wall and stick a fan in it.  Now, it blows the stink from one stall to the other!

Suggestion to visitors: Use the stall on the right.

Monday, March 8, 2010

How To: Screen Captures

After using Irfanview to do some serious screen capturing, I think it is probably the easiest/best tool around.

How To use Irfanview for screen captures:

1. Download the program: http://www.irfanview.com/ 
      a. Note that there are two downloads: Irfanview and the plugins.
2. Install and run it.
3. Choose Options -> Capture/Screenshot (or just hit the letter "c")
4. Choose the type of screenshot - full screen, foreground window, rectangle, etc.
5. Choose how you want to save it - there's two options:
     a. When you take the screenshot it opens an irfanview window for editing
     b. Or you can save directly to a file. Give the filename format, a directory name, and the image format.
6. There is also a checkbox to choose whether or not to include the cursor in the image
7. Click "Start"
8. Irfanview now runs in the background. Just type "Ctrl-F11" to get a snapshot.

MS Word 2007 Macros

As the documents that I am writing keep getting bigger, simple tasks, like reformatting every table in the document, are getting harder. So, I turned to Word macros for help. The list below contains some of the macros that I have found that make (my) life easier.





Word Tips



  1. How do I print multiple copies of a single page on 1 page?
  2. How do I copy footnotes to another document?
  3. How do I paste without formatting (quickly)?
  4. How do I reformat all the tables in a document?
  5. How do I update all the fields in a document?
  6. How do I make all the references (Figures, Tables, etc.) formatted in Italics?



Sunday, February 21, 2010

Saving images from MS Word 2007

What's the easiest way to save images that are in an MS Word 2007 file?  Word 2007 changed the file format from .doc to .docx, which is really just a zip file (Like Java jar files).  Just change the file extension from .docx to .zip and then extract it with any Zip program (like Winzip).  Inside the extracted directory there is a sub-directory with all the graphics in the file along with XML files that describe the document.

[Tip from Graham Mayor]

Monday, February 1, 2010

MS Word Tip of the Day - Pasting unformatted text

If you copy and paste text from one document (or the internet) into an MS Word document, you've probably come across the formatting problem. When you paste the text it retains the formatting from the source document. I found a nice article on the MS site on how to create a work around which pastes unformatted text (refer to article at Microsoft site).

The idea is to create a macro that uses this line:
  • Selection.PasteSpecial DataType:=wdPasteText
Assign this macro to a key. I chose Ctrl+Shift+v so that Ctrl+v does a regular paste, and add "shift" for unformatted pasting.

Sunday, January 10, 2010

Good Deed of the Day

I went out for a walk last night and noticed that my neighbor's big black dog got out of their yard again and was wandering around the neighborhood.  I figured that I would do my good deed of the day and take him back.  Luckily, when I called his name he actually listened and came right over.  I then took him back to their house, opened the gate, and he ran right in.  I locked the gate and gave myself a pat on the back for a job well done.

There was only one problem.... it wasn't their dog!

Monday, January 4, 2010

Parking Lots

Growing up, my family drove a 1976 Volvo station wagon which we affectionately called "Helga". Helga had about 30,000,000 miles on her and you could feel things hit your feet as we drove because the floor was rusted out. Just about every part on the car had been replaced at some point, except for the odometer which broke after 17 years.  But who needs an odometer?  We didn't need to know when 5000 miles had passed since the last service because Helga went to the garage once a week for some random problem.

Now, being that Helga was a special car, she had to have a special parking spot.  If we went to a shopping mall, my father would park the car in the last spot in the lot.  This is the spot no one wants because it is so far from the store entrance.  You almost need to catch a taxi to get there. If we were in a small parking lot, then my father would never park our straight in a parking space.  He would always park diagonally and take up two spaces.  This way no one would put a ding in the side of the car.  Did I mention that the car was completely rusted out?  Did I mention that it had a billion miles on it?  At least we didn't have any dings in the doors.

So, I felt a little nostalgia when last week I came across this parking job:


I am searching for an explanation but not finding any.  Maybe there was no other place to park? No.  Maybe he had a nice shiny new car? No. Maybe the lines were faded? No.

Well, it looks like he doesn't have any dings in his doors either.