Software: April 2006 Archives
Ok, here's one for the masses.
This post describes how to add info about the song currently playing in iTunes to emails you compose in Outlook. Anyone can do it!
First, create the macro. To do so:
- Open Outlook.
- From the Tools menu, select Macro, then Macros...
- In the Macro field, enter a name for your macro. "AddiTunesSig" is probably appropriate. [screenshot]
- Click "Create".
- A "code window" will open. This is where, in a minute, you will type the code that makes up the macro.
- But first, you need to tell Outlook how to talk to iTunes. To do so, go to the Tools menu and select References. Scroll down until you find "iTunes Type Library" or something similar. Select its checkbox and click OK. [screenshot]
- Back in the code window, you will see two lines of code:
Sub AddiTunesSig()andEnd Sub. In between these lines, paste in the following code:' purpose: opens a new mail message, ' appends info re: currently playing track in iTunes Dim itunes As iTunesApp Dim strArtist As String Dim strTitle As String Dim strOutput As String Dim mail As Outlook.MailItem Set itunes = New iTunesApp 'load the track info into easy-to-read variables strArtist = itunes.CurrentTrack.Artist strTitle = itunes.CurrentTrack.Name strAlbum = itunes.CurrentTrack.Album 'assemble the signature strOutput = vbNewLine & "------------------------------" strOutput = strOutput & vbNewLine & "Now playing: " & vbCrLf _ & strTitle & vbCrLf & strArtist & vbCrLf & strAlbum 'create a new email message Set mail = Outlook.CreateItem(olMailItem) 'put the signature in the body mail.Body = vbNewLine & vbNewLine & strOutput 'show the message to the user mail.Display 'clear up the memory Set itunes = NothingSee how easy programming is! [screenshot]
- To finish up: Click the Save button on the toolbar and close the code window.
Now, you need to add a toolbar button to your Outlook toolbar that will run this macro. To do so:
- Go to the Tools menu, and select Customize...
- In the dialog box that pops up, scroll down the left side, and click Macros. [screenshot]
- You will see your macro on the right ("Project1.AddiTunesSig"). Drag it up to a convenient location on your toolbar. (Next to the "New" button is probably a good place.)
- To rename the button, right-click the button and type the new name where it says "Name:" in the pop-up menu. "New (with music)" is probably a good name. [screenshot]
- Close the Customize window.
That's it! To use it, open iTunes, play a song, go back to Outlook, and click your new button. A new email will open with info about the currently playing song in the signature area.
Earlier: How to control iTunes from any Microsoft Office application.
