Main | August 2005 »

July 30, 2005

Create a hyperlink in Word from a drop down list

Creating a hyperlink in Word through Visual Basic for Applications (VBA), the programming language for Word, involves two three steps. Inserting the text to be dislayed as the hyperlink, selecting that text, attaching a URL to the text. Sounds complicated, but it's not.

The extra step that you are looking, creating the hyperlink based on a selection from a drop down list is just as easy.

First thing to do, enter the code into the VBA editor. Click Tools->Macro->Macros. Type URLLink into the Macro Name field. Select Document1 or whatever the name of your current document is to store the macro inside the document itself. Click Create.

Word will open the VBA editor and enter the beginning and ending statements of the macro along with comments reflecting your name and the current date. Enter the following text, minus the Sub and End Sub commands. See below for an explanation of how the code works.

Sub UpdateURL()
'
' UpdateURL Macro
' Macro created 7/28/2005 by Westley Annis
' http://www.AskWestley.com
'
Dim strField As String, strURL As String
Dim bmrkURL As Bookmark
    strField = ActiveDocument.FormFields("Dropdown1").Result
    strURL = "https://www.companyurl.com/" & strField & "/Metrics/Forms/AllItems.aspx"
    ActiveDocument.Unprotect
    ActiveDocument.Bookmarks("URLLink").Range.Select
    Selection.Expand unit:=wdSentence
    Selection.TypeText Text:=strURL
    Selection.Expand unit:=wdSentence
    ActiveDocument.Hyperlinks.Add Address:=strURL, Anchor:=Selection.Range
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

Exit out of the VBA editor and back into Word. Add the following elements to your document.

A dropdown FormField (right-click on any toolbar to show the list of toolbars available and select Forms if not already checked - click the dropdown button then click inside the document to insert it). Right-click on the dropdown formfield and select Properties. Add the text of each option you would like displayed inside the dropdown box and enter Dropdown1 in the Bookmark field.

Create a MacroButton to execute the URLLink macro when clicked by clicking Insert->Field, select MacroButton from the Field names list, enter "Click here to create hyperlink" in the Display text field, and select URLLink from the Macro name field. Click Ok.

Create an empty paragraph to hold the URL and insert a bookmark by clicking Insert->Bookmark, type URLLink in the Bookmark name field, click the Add button.

Protect the document for forms by clicking the Protect Form button on the Forms toolbar. You're all set.

Select an element from the drop down list and click on your macro button, your hyperlink will be entered.

For those that don't understand VBA code, here's a play-by-play account of what's happening.

The two lines that begin with Dim are creating storage locations to hold the element that was selected, the URL that gets built, and a reference to the bookmark where the URL will be inserted. The next line gets the actual element that was select while the following line builds the URL by adding the necessary information in front and behind the selected element.

Next the document is unprotected so that text can be entered. The cursor is moved to the URLLink bookmark and the text entered. The just entered text is then selected and the hyperlink is attached to it. Finally the document is reprotected for forms with the NoReset flag so that any entered information is not lost.

Posted by admin at 12:40 AM | Comments (0) | TrackBack

July 27, 2005

Moving My Documents

There are several ways to move the My Documents folder within Windows. Perhaps the simplest method is to do a right-click on the folder, select Properties, and click the Move button. Select a new destination, click Ok and the My Documents folder is moved.

The important thing to remember is to already have another folder named "My Documents" in the new destination. In other words, if you want to move to the D: drive be sure to select "D:\My Documents" and not "D:\"

Windows has numerous other User folders and Shell folders that can also be redirected to other locations. However, moving these requires making changes to the registry, not something to be taken lightly, since one small mishap can render Windows unbootable.

Microsoft MVP Kent W. England has a Web page where he lists the numerous special folders inside Windows and how to move them.

Posted by admin at 5:54 PM | Comments (0) | TrackBack

July 25, 2005

Mississippi Casino Shows

With six different casinos on the Mississippi Gulf Coast it can be difficult to keep track of who is performing at what casino and where. MississippiCasinos.com maintains a page with the announced shows for Beau Rivage, Grand Casino Gulfport and Biloxi, Casino Magic Bay St. Louis and Biloxi, and Imperial Palace Biloxi.

Although MississippiCasinos.com has all the shows listed there are no convient links to the individual hotels for a more detailed information or to order tickets.

Listed below is a link to the entertainment schedule for each hotel:

  • Beau Rivage

  • Grand Casino Biloxi

  • Grand Casino Gulfport

  • Casino Magic Biloxi

  • Casino Magic Bay St. Louis

  • Imperial Palace Biloxi
  • Posted by admin at 8:59 PM | Comments (0) | TrackBack

    How to use Windows XP Remote Assistance behind a firewall

    Windows XP Remote Assistance allows you to have someone else connect to your computer over a network connection for training or technical support purposes. Both you and the person connecting to your machine can view your Desktop and any applications that may be running. However, the person connecting remotely cannot do anything on your machine, such as move the mouse or use the keyboard, until you have granted them permission to do so.

    Remote Assistance is built on the same technology as Windows Terminal Services and Windows XP Remote Desktop.

    Before someone can connect to your machine you have to send them an invitation do so, usually thru email. The email contains a file attachment with named RAInvitation.msrcincident for the invitee to double-click on to connect to your machine. Should make it all a simple matter of invite, email, double-click, bam! You're connected.

    You actually run into two problems, especially for those who are using high-speed Internet connections behind a router/firewall. One, the address of your computer, which is inside the RDP file, is going to be your private IP address for use behind your router. The invitee is usually not connected to your network so he can't reach that address. Two, your firewall is most likely blocking port 3389, which is the Internet port that Remote Assistance works with.

    So, how do we clear this up? Let's start with problem one first, your IP address. Save the invitation to a file first, by clicking on the Save invitation as file option. This will save it in your My Documents folder by default, although you have the option of changing locations.

    Open your My Documents folder, find the RAInvitation.msrcincident file, right-click on it, select Open With from the menu, then select Notepad. You're now looking at the XML formatted data that is your invitation.

    <?xml version="1.0" encoding="Unicode" ?><UPLOADINFO TYPE="Escalated"><UPLOADDATA USERNAME="Owner" RCTICKET="65538,1,192.168.1.195:3389;Server:3389,*,vIVJ0wXdKVojxwE8G9r 3cwyY8xLmqnvQmdjkElWA84Q=,*,*,ofzeBc3RjJoErIZFCKACEgKxVQ4=" RCTICKETENCRYPTED="1" DtStart="1119369569" DtLength="43200" PassStub="n8!8LhEcggQ5iA" L="0" /></UPLOADINFO>

    Everything is contained within the data string labeled UPLOADDATA. More important, what we are worried about is the information inside the string RCTICKET.

    It is pretty easy to pick out the IP address, which starts after the second comma (192.168.1.195 in this example). By changing the IP address to match your external IP address, the invitee will be able to find your router from the Internet.

    The simplest way to get your IP address is to visit http://www.whatismyip.com/. Only thing this website does is display your IP address.

    Make the change to the IP address and close the file, saving your changes. Before emailing the invitation off, you need to configure your router to send all traffic over port 3389 to your machine. Since there are many different types and brands of routers, each of which is configured differently, I can't give you specific information on how to do this. Check your documentation on how to configure Virtual Servers and point 3389 TCP to your computer.

    Posted by admin at 6:45 AM | Comments (0) | TrackBack

    July 24, 2005

    How can I add an EXE file to a Word toolbar?

    Microsoft Word is a very powerful and flexible program, especially when it comes to it toolbars or CommandBars, as Microsoft refers to them.

    There are two different methods of creating having a button point to an outside program. One is by using a hyperlink and the other is by using a Visual Basic for Applications (VBA) macro. Both are simple to the do and the only difference is in how the external program is called, which also changes how Word reacts in regards to security.

    When using a hyperlink, Word treats it as coming for an unknown source and will display warnings asking if you really want to launch the program. It's the same as when you click on a EXE file from inside Internet Explorer, a warning displays telling you of the dangers of using an unknown program.

    With a VBA macro, all the security settings are based on the trustworthiness of the macro itself. Once you allow the macro to run, everything it does is deemed to be safe, so the external program will launch with no warnings.

    Safety issues aside, I'm going to focus on the VBA method since I think most folks would only be adding an EXE to their Word toolbar that they already trust and would become annoyed with the extra warnings rather quickly. Also, although I'm using Word here, these steps can be repeated in just about every other Microsoft Office application.

    The steps outlined are for Word 2003 and may vary slightly for other versions of Word.

      Step 1: Create a VBA macro to launch the external program (Notepad.exe for this example)
    1. Click Tools->Macro->Macros

    2. Type "RunNotepad" and click Create

    3. Enter the following inside the VBA editor, the Sub and EndSub lines are entered automatically by the VBA editor


    4. Sub RunNotepad()
      Shell Pathname:="C:\WIndows\Notepad.exe", _ WindowStyle:=vbNormalFocus
      End Sub

    5. Close the VBA editor by clicking on the Close button


      Step 2:Add the new macro to the toolbar
    1. Click Tools->Customize

    2. Select the Commands tab.

    3. Under Categories, scroll down and select Macros.

    4. Under Commands, find the name of your macro and drag it to the Toolbar and position it where you want.

    5. Right-click on the new button you've just created (it's going to be all text) and select either "Edit Button image" to draw your own button or "Change Button image" to select a pre-drawn image.

    6. Click Close after working with your button image and your all done.

    The Shell command supports several different options for how the external program is opened. View the VBA help file for more information.

    Posted by admin at 11:30 PM | Comments (0) | TrackBack

    July 21, 2005

    Are Snoball's really that great?

    Absolutely! Nothing beats the heat and humidity of New Orleans like a Snoball!

    For those who haven't experienced a New Orleans style Snoball let me just say that they are like snocones, only better. The difference between the two is that a snocone is made of crushed ice. Anyone can make a snocone by putting ice in their blender.

    Snoballs on the other hand are made from finely shaved ice. The ice is so fine that it literally resembles real snow. Pour on your favorite flavoring, which gets absorbed by the ice and you've got a cool, frosty treat that is just right in the middle of summer.

    Who makes the best Snoballs? Well, that all depends on what neighborhood you live. Everyone has their own personal favorite, which is usually just around the corner from where they live.

    My favorite is Frosty's Snoball's on E. Judge Perez Dr. next to Beau's. They make the best sour apple in all of St. Bernard Parish.

    Want to show your appreciation for the effort I've put into answering your questions? Then buy me a Snoball! Even better, but the whole family a Snoball for putting up with me at the keyboard so much. I'll even list your name and website as a donor!

    Posted by admin at 9:30 PM | TrackBack