Friday, May 30, 2008

Visio Org Charts: Change Border Color Based on a Custom Property

I recently was asked to modify an existing Visio Org Chart based on a custom property. Every person in the org chart had a custom property for a BlackBerry number. Based on whether the person had a blackberry number or not, my client wanted the border to be set to a thick red line.

I came up with the following code to do just that:

Sub set_blackberry_border_red()
Dim vsoPage As Visio.Page
Dim VsoShp As Visio.Shape
Dim i As Integer

For Each vsoPage In ActiveDocument.Pages
' Loop through each page
For Each VsoShp In vsoPage.Shapes
' Loop through every shape on the page
If Not VsoShp.OneD Then
' Shape is not a line
nrows = VsoShp.RowCount(Visio.visSectionProp)
' Set shape to normal border
black_border VsoShp
For i = 0 To nrows - 1
' Look at all properties
If VsoShp.CellsSRC(Visio.visSectionProp, i, visCustPropsLabel).ResultStr(Visio.visNone) = "Blackberry" Then
' If property is blackberry phone number...
If VsoShp.CellsSRC(Visio.visSectionProp, i, visCustPropsValue).ResultStr(Visio.visNone) <> "" Then
' ... set its border color to red
red_border VsoShp
End If
End If
Next i
End If
Next VsoShp
Next vsoPage
MsgBox "Finished.", vbInformation
End Sub

Sub red_border(shp As Visio.Shape)
' Set border size thicker
shp.CellsSRC(visSectionObject, visRowLine, visLineWeight).FormulaU = "1.2 pt"
' Set Border color to red
shp.CellsSRC(visSectionObject, visRowLine, visLineColor).FormulaU = "2"
End Sub

Sub black_border(shp As Visio.Shape)
' Set border size to thin
shp.CellsSRC(visSectionObject, visRowLine, visLineWeight).FormulaU = "0.24 pt"
' Set border color to black
shp.CellsSRC(visSectionObject, visRowLine, visLineColor).FormulaU = "0"
End Sub

Thursday, May 15, 2008

Microsoft Live Map of where I've lived

video

This animation was created using the Microsoft Live Map tool. You can reach the tool at http://www.3dMapTour.com. I was impressed with how easy this was to create, and a little impressed at how far I've come to end up where I am.

Why Burma doesn't want our help

The introduction to Disasters and Development by Fred Cuny gives an explanation of why dictatorships want us to give aid to the government for distribution and not directly to the disaster affected population. I read this and immediately thought of Burma:

...In reality, just as disasters and development cannot be separated, neither can disaster response be divorced from politics. Unfortunately, few governments in the Third World are democratic and many regimes perpetuate underdevelopment because it supports the needs of an oligarchy or other privileged class. Thus many of the ideas presented here are anathema to these groups. For them, control of disaster relief is another way of maintaining the status quo, and a paternalistic dole of relief goods from foreigners is the preferred method of aid, for it is in keeping with the dictatorial system.

How a hurricane forms: an explanation by Fred Cuny

I'm reading Disasters and Development by Fred Cuny. It's an excellent work by one of the most important people in the Disaster Relief field. Fred Cuny engineered the repatriation of 400,000 Kurds after Gulf War I, arguable saving the lives of tens of thousands of people. Cuny disappeared in Chechnya in 1995.

Disasters and Development has one of the clearest explanations of how a hurricane forms that I have ever seen:

Much is known about how a cyclone forms. In order to develop, a cyclone must have a warm sea and calm warm air. The warm air rises -- heavy, humid, and full of water vapour. Its place is taken by air rushing in from the sides and, because of the earth's rotation, this moving air is given a twist, so that the entire system begins to revolve. The warm rising air meets cooler air and releases its water vapour in the form of rain. It takes a tremendous amount of energy for the air to lift the water in the first place, and now this energy is released in the form of heat. This increases the rate of ascent of the air and a continuous cycle begins to develop. More water is released and also more heat : more the water and heat released, faster the cycle moves. This cycle becomes the engine that drives the beast, and gradually it goes faster and faster and the air mass becomes much larger.

Because the wind system is revolving, centrifugal force tends to throw the air outward so that the pressure in the center becomes very low, thus forming the eye of the storm. The pressure on the outside is very high, so the wind moves faster in an attempt to fill that low pressure area. The faster it moves the more the centrifugal force throws it outward. Soon there are very fast circular winds and, when they reach 120 kilometers per hour, the system becomes a cyclone or hurricane.

The system then begins to move forward like a spinning top. This brings it into contact with more warm sea and air, and the process becomes self-sustaining. Once a cyclone is formed, it will continue to move and expand until it passes over land or over an area where the sea is cooler.

In the northern hemisphere, cyclones generally move in a north-westerly direction; in the southern hemisphere, in a south-westerly direction. Little is known about what makes these storms move and change direction, other then that they are affected by the high altitude winds and rotation of the earth. So far, scientists have found it difficult to predict the movement of the cyclone, making this hazard one of the most dangerous.

Thursday, May 8, 2008

How to reinstall the Windows TCP/IP stack

It's been a long time since I blogged anything technical. In my current job I am quite far from technology, which is a drag, but kind of part of the dues of moving along in my career. However, I still get some opportunities to do geeky stuff.

For example, my neighbor just called me with a problem with his Windows XP machine. He had gotten hit with a virus. Norton took care of it, but his browser no longer worked.

I fired up a command prompt and pinged google. I got this:

Pinging www.l.google.com [ºÿ] with 32 bytes of data:
Reply from 64.233.167.99: bytes=32 time=63ms TTL=245
Reply from 64.233.167.99: bytes=32 time=63ms TTL=245
Reply from 64.233.167.99: bytes=32 time=63ms TTL=245
Reply from 64.233.167.99: bytes=32 time=63ms TTL=245
...

Which was kind of what I expected, except for the weird ºÿ characters in the first line. I started to suspect that my neighbor's TCP/IP stack was messed up. In the past, I seemed to remember fixing this by deinstalling TCP/IP and reinstalling it.

But when I went to deinstall TCP/IP, I saw that the "uninstall" button was grayed out. Hmm.

A little research on the Internet (always have a second computer!) revealed a single command that could be used to "reinstall" TCP/IP. It doesn't really reinstall it, it just resets the configuration of it:

netsh winsock reset

After this, Windows asked me to restart. When I went to the signoff login, the "Shutdown" button had a message that stated that shutting down would install a necessary update. I chose to shutdown.

When the PC rebooted, everything worked! There are more details on this technique here:

http://support.microsoft.com/kb/811259