Early Spring – The Flowers (Part 2)

It wasn’t long ago and my spring flowers were mere nubs in the ground. Well, things have certainly changed and now I’m seeing the first blooms! The crocus always seem to be the first to produce a bloom. Perhaps it’s because they have almost nothing in the way of leaves, so they focus all their energy on the lovely flowers they produce. I have two colors of crocus in my garden as shown here:


Of course, it won’t be long and more flowers will make their appearances. I’ll keep you updated as more flowers create a riot of color in my backyard. Spring flowers are always so welcome because they signal the end of winter.

Now, if only the weatherman would get the message. We’re supposed to get snow tonight. It won’t hang around, but the very idea that it’s coming is a reminder that winter hasn’t quite made a disappearance yet. What are your favorite spring flowers? Let me know at John@JohnMuellerBooks.com.


Deleting a Session at the Command Line

A reader of my book, Windows Command-Line Administration Instant Reference, recently wrote in to say that the Net Sessions /Delete command apparently doesn’t work, which I found interesting because I’ve tested it on a number of occasions and found it always worked for me. It turns out that we had two different scenarios in mind. Normally, you’ll use the Net Sessions /Delete command to free up resources when a remote terminal has frozen or left the session intact in some other way. For whatever reason, the remote user didn’t log out and that means all of the file locks are still in place, for one thing, and that all of the session resources are in use, for another. Using Net Sessions /Delete cleans up this mess, but only at the potential expense of data loss and all of the other things that go with terminating a session without following the usual protocol.

In this case, the reader was simply trying the command to see if it would work. However, the command didn’t appear to work become the remote terminal was still active. Since Windows XP SP1 there has been an automatic reconnection feature.  You disconnect the session and Windows XP (and above) automatically reconnects it. You can read about it at http://support.microsoft.com/kb/323258.

Microsoft used to say that you had to turn this feature on manually (such as by using a policy). The fact of the matter is that the sessions automatically reconnect by default. You’ve probably seen it work already. For some reason, the network disconnects. However, after a few seconds, you magically see the network connection reappear. I know I’ve even seen it on my network. There isn’t anything magic about it—the session is being automatically reconnected in the background without any interaction from you. So…while the command does in fact work, it’s disabled by the automatic reconnection feature. Windows can reconnect faster than you can disconnect it.

Of course, this makes me wonder about other commands that apparently don’t work, but are merely thwarted by well-intentioned Windows behavior. Let me know if you see any behavior of this sort at John@JohnMuellerBooks.com.

SendKeys in VBA

The SendKeys statement in VBA is one of the more interesting features because you can use it to send keystrokes directly to the user interfacejust as if you were entering the keystrokes yourself. This means you can use SendKeys to perform all sorts of tasks that you might not ordinarily be able to perform using other statements. For example, you could use SendKeys to modify the Ribbon interface programmatically.

Unfortunately, SendKeys can also cause problems for the VBA developer. I’ve received more than a few e-mails regarding SendKeys examples not working properly. For example, Listing 5-8 in VBA for Dummies causes a lot of woe for many readers. The natural inclination is to want to watch the macro run from within the Visual Basic for Applications editor, but you can’t do this with SendKeys. The SendKeys statement always sends its output to the active windowno matter which window that might be. So, if you have the Visual Basic for Applications editor selected, the SendKeys output goes to that window, rather than the Excel window where the output would normally go when a user is running the macro.

So, just how do you run this macro? If you want to see the macro work in the debugger, you begin by setting a breakpoint in the editor. Simply click in the margin area on the left side of the editor and you’ll see a breakpoint added like the one shown here:


The breakpoint line appears highlighted in red. You also see a red circle in the left margin. When you run the macro, it’ll stop at the ActiveRows = ActiveWindow.RangeSelection.Rows.Count line.

At this point, you can run the macro. Open the Developer tab and you’ll see a Macros button in the Code group as shown here:


Click the Macros button and you’ll see the Macro dialog box shown here:


Select the ChangeAllRooms macro from the list. Click Run. The macro will run to the breakpoint you selected.

Now, if you run the macro shown in Listing 5-8, you’ll see that SendKeys is actually broken in VBA in Office 2010 (it worked fine in earlier versions of Office). The key combination is sent, but usually after the rest of the macro has run. The second part of the callthe part that tells VBA to wait until the SendKeys call is processed before proceeding is broken. Consequently, the code to tell Excel to select a column by pressing the Ctrl+Shift+Down Arrow keys doesn’t work. The key combination is sent to the window, but long after the need for the key combination has passed. If there is someone who has a solution to this problem, let me know at John@JohnMuellerBooks.com. In the meantime, you can get this example to work using the following code instead.

Public Sub ChangeAllRooms()
    Dim ActiveRows As Integer   ' Number of active rows.
    Dim Counter As Integer      ' Current row in process.
    ' Select the first data cell in the worksheet.
    ' Use SendKeys to select all of the cells in the column.
    ' This call is broken in Office 2010, so I commented it out.
    'SendKeys "^+{DOWN}", True
    ' Select the range manually for the example instead.
    Range("A5", "A10").Select
    ' Get the number of rows to process.
    ActiveRows = ActiveWindow.RangeSelection.Rows.Count
    ' Reset the cell pointer.
    ' Keep processing the cells until complete.
    For Counter = 5 To ActiveRows + 5
        ' Call the Sub created to change a single cell.
        ' Move to the next cell.
        Range("C" + CStr(Counter)).Select
End Sub

OK, now that you have working code, you can run the example. Here are the results you should see from Listing 5-8.



VBA in Office 2010

Office 2010 has a lot to offer to the Visual Basic for Applications (VBA) developer. Of course, all of the things that I discuss in VBA for Dummies still applies. You can still create great VBA applications using Office 2010. However, there are many new twists with Office 2010 as well, such as a new version of VBA, VBA 7.0. Many of the differences in VBA 7.0 are due to the 64-bit release of Office 2010, but there are many other goodies that I plan to introduce as the weeks pass.

However, before I get into anything very complicated, let’s address a simple need that several readers have written aboutnamely gaining access to VBA in the first place. It appears that Microsoft has simplified the Office interface to the point of making some things hard to find. In order to start using VBA, you need to expose the Developer tab on the Ribbon. The following steps will get you started:


  1. Choose File > Options. You’ll see the Options dialog box (such as Word Options in Word).
  2. Select the Customize Ribbon folder. You’ll see a list of tabs in the right pane as shown here:
  3. Check the Developer tab and click OK. You now have access to VBA. Here’s how the Developer tab looks in Wordthe other Office applications provide a similar view:

Now that you have access to the Developer tab, you should try creating a macro. One of the things I’ve been encouraging readers to do is to spend more time recording macros. Recording a macro helps you understand the actual code used to perform the tasks that you normally perform better. So, let’s try something simple in Word 2010.


  1. Click Record Macro. You’ll see the Record Macro dialog box shown below. Begin by filling out the information shown in the screenshot. This dialog box looks similar to the version used in previous versions of Office, but there are some things to consider. First, notice that you can now assign macros to buttons on the Ribbon, so your macros no longer have to hide somewhere. When you assign your macro to a button in a template, everyone using the template will see that button, so VBA is definitely becoming Ribbon friendlier.
  2. Click Button. You’ll see the Word Options dialog box. Microsoft assumes you want to place the new macro on the Quick Access Toolbar (QAT), but this is a bad idea. Most developers reserve the QAT for users, so they can easily customize their Office interface.
  3. Select the Customize Ribbon folder. Choose Macros from the Choose Command From list. You’ll see your macro in the list. Let’s put the macro on its own custom tab in its own custom group.
  4. Click New Tab. You’ll see a New Tab (Custom) and a New Group (Custom) added to the Main Tabs list.
  5. Highlight New Tab (Custom) and click Rename. You’ll see the Rename dialog box shown here:
  6. Type My Custom Tab and click OK. You’ll see the name change appear in the Main Tabs list.
  7. Highlight New Group (Custom) and click Rename. You’ll see a different Rename dialog box this time as shown here:
  8. Type Test Macros. Select the green right arrow as a symbol. Click OK. You’ll see the name change appear in the Main Tabs list. It’s time to add our macro to the Ribbon.
  9. Highlight the macro entry in the macro list. Highlight the Test Macros (Custom) entry in the Main Tabs list. Click Add. Word adds the macro to the custom Ribbon entry. Your Word Options dialog box should look like the one here now:
  10. Click OK to accept the changes. At this point, you can start recording the macro. Let’s do something very simple this time.
  11. Type Hello World in the Word document. Click Stop Recording. Word stores the macro you’ve just created.
  12. Select the My Custom Tab tab on the Ribbon. You’ll see something like this:
  13. Click the Test Me macro. You’ll see Word Type Hello World.
  14. Click Visual Basic on the Developer tab. You’ll see the Visual Basic editor opened.
  15. Double click the Project (Document1)\Modules\NewMacros entry. You’ll see the source code for the macro you just created, which will look something like this.
Sub TestMe()
' TestMe Macro
' This macro shows the results of using the Macro Recorder in Word 2010.
    Selection.TypeText Text:="Hello World"
End Sub

That’s all there is to it! You can create macros now that will appear anywhere on the Ribbon. Give it a try and use this technique to start all of your macros in the future. I’ll visit the new VBA features in greater detail in future posts. In the meantime, contact me with your questions at John@JohnMuellerBooks.com.


Using the PTVS for a Windows Forms Project

Chapter 8 of Professional IronPython demonstrates how to create a Windows Forms application using IronPython 2.6. As mentioned in my previous post about IronPython, IronPython 2.7 provides something new in the way of integration, PTVS. You’ve already discovered the means to create a console application using PTVS in my second post on this topic. This post goes a step further and demonstrates how to create a Windows Forms application using the same approach you’d normally use with any other .NET language, such as Visual Basic .NET or C#. I assume you already have PTVS installed on your system.

Of course, you begin by opening Visual Studio 2010 as normal. The New Project dialog box should contain a WinForms Application template in the IronPython folder. If you don’t see the correct template, then you probably don’t have IronPython 2.7 installed with Visual Studio 2010 (see my previous post for details). Call this project PythonApplication2 as shown here:


Click OK and Visual Studio creates the solution for you. The next step is to recreate the display shown in Listing 8-1 of the book. I had truly hoped that PTVS would provide Designer support, but it doesn’t. Here’s what you get as output from the template:


Now, it is disappointing that you don’t get a Designer, but the template does provide you with some helpful information and it’s better than what you started with in Chapter 8. The updated code is easier to read and requires that you perform less typing than shown in Figure 8-1. Here’s the new version of Listing 8-1.

import clr
from System.Windows.Forms import *
from System.Drawing import *
class MyForm(Form):
    def __init__(self):
        # Add a tooltip control.
        Tips = ToolTip()
        # Configure btnOK
        btnOK = Button()
        btnOK.Text = "&OK"
        btnOK.Location = Point(263, 13)
        Tips.SetToolTip(btnOK, 'Displays an interesting message.')
        # Configure btnCancel
        btnCancel = Button()
        btnCancel.Text = "&Cancel"
        btnCancel.Location = Point(263, 43)
        Tips.SetToolTip(btnCancel, 'Cancels the application.')
        # Configure lblMessage
        lblMessage = Label()
        lblMessage.Text = 'This is a sample label.'
        lblMessage.Location = Point(13, 13)
        lblMessage.Size = Size(120, 13)
        # Configure the form.
        self.ClientSize = Size(350, 200)
        self.Text = 'Simple Python Windows Forms Example'
        self.AcceptButton = btnOK
        self.CancelButton = btnCancel
        # Add the controls to the form.
form = MyForm()

This code works precisely the same as the code described in Listing 8-1. You still see the same dialog box as output as shown here:


It isn’t anything fancy, but the example does demonstrate that you can create a Windows Forms application using straightforward code and less typing than the example in Listing 8-1. Of course, this form requires event handlers, just like the ones used for the example in Chapter 8. Of course, you begin by creating the required linkage after you initialize the form as shown here:

# Add the event handler linkage.
btnOK.Click += btnOK_Click
btnCancel.Click += btnCancel_Click

After which, you add the event handler code shown here:

# Define the event handlers.
def btnOK_Click(*args):
    # Display a message showing we arrived.
def btnCancel_Click(*args):
    # Close the application.

At this point, you have the same first example shown in Chapter 8. Of course, Chapter 8 contains a number of other examples that demonstrate other techniques; all of which you can easily move to the new environment provided by PTVS. Here’s the source code for the entire example: Program.py. So, what do you think of the new Windows Forms project support provided by PTVS? Let me know at John@JohnMuellerBooks.com.

Considering the Economics of Accessibility

People have asked in the past which book of mine is my favorite. I have a number of answers to that question. In one respect or another, all of my books are my favorite because they all answer different questions and help a different group of people. As I’ve mentioned in the past, the reason I write is because I truly enjoy helping others.

My reasons for writing “Accessibility for Everybody: Understanding the Section 508 Accessibility Requirements” are many. However, one of the biggest reasons that I wrote it is because there are good economic reasons to make applications accessible to everyone. Not all of these reasons have a direct monetary impact, but I do express them in the first chapter of the book. The fact of the matter is that if your application isn’t accessible, you’re costing your company time and money. If you’re a store owner, you’re losing money every second that your organization uses applications that aren’t accessible.

people associate accessibility with those who have special visual or
audio needs.  However, accessibility affects quite a large group of
people, including those who are colorblind. Did you realize that about 8% of the male population is colorblind,
which means that if your application isn’t accessible to this group
that you’re losing out on 8% of your sales right off the top? Can you
really miss out on that many sales? In short, accessibility is truly for everyone and everyone includes you.

It amazes me that some organizations just don’t seem to get it. Accessibility affects more than those people across the street; they affect you personally. At some point in life, you’re going to need an accessibility aid. Our eyes get older and can’t see as well, the ears refuse to hear, things wear out. So, the accessibility features you add to an application today will ultimately help you in some way. It’s the reason that I read about lawsuits such as the one between the National Federation of the Blind, NFB, and Google, and have to scratch my head. I have to wonder why such a lawsuit is even necessary.

Another reason I wrote my book is to show how easy it is to make applications accessible and to inform my readers about the laws regarding accessibility (laws that our government doesn’t enforce).  Creating an accessible application with the tools available today isn’t a major undertaking. In many cases you’re looking at a few extra minutes to add features such as speed keys and titles that a screen reader can read (the same titles appear as balloon help that sighted users also rely upon). It’s true that applications that make heavy use of full animation or video can become harder to make accessible, but these applications are in the minority. Most business applications require very little extra work.

If you think buying a book to learn about accessibility is just too expensive, I encourage you to make use of the free resources available on the Internet. Companies such as Microsoft want you to create accessible applications because they realize that it’s in their best interest to do so. These resources are incredibly easy to use and they make life easier for everyone. I’m always happy to hear about your insights regarding accessibility, so feel free to contact me at John@JohnMuellerBooks.com.


Early Spring – The Garden and Orchard

Spring really begins to take off with the introduction of new growth in the garden. Our permanent bed has a number of items in it; some start early, while others wait a while to make their presence known. About the earliest arrival in the garden is the rhubarb; a favorite of mine. Nothing quite matches the sour taste of rhubarb, especially the first growth of spring. Rhubarb looks like little red balls when it first appears, and then you begin seeing leaves like these shown here:


Of course, it’ll be a while before I’ll enjoy any fresh rhubarb. I’ll show you how it looks later. One of the ways I like it best is freshly picked with just a tad of sugar. It’s also good in rhubarb rolls and we make wine from it (among other things).

Another early arrival are Egyptian walking onions. They’re called walking onions because they literally walk from place to place in your garden. The top of the onion sprouts a seed head. When the seed head become too heavy for the stalk, it ends up on the ground and replants itself; no extra work on your part! Here’s what the walking onions look like in the garden:


When these onions get large enough, I’ll dig up just a few and enjoy them very much as I would green onions. The Egyptian walking onion tends to be a little stronger and a little larger than the green onions you buy in the store, but you can use them precisely the same way. Here is a patch of ground that shows the seed heads as they appear in spring:


Each one of those tiny little heads will become another onion. We should have quite a wealth of them this year. The Egyptian walking onion is our second taste treat from the garden. The first taste treat is horse radish. The horseradish isn’t quite up yet; at least, it isn’t far enough up to tell what it is. Normally, you’d dig it up this time of year though, grind it up, add some vinegar, and enjoy.

Another spring delight is asparagus. I’ll be sure to upload some pictures of it when it comes up. Asparagus is planted very deep and doesn’t make an appearance yet for at least another two weeks (probably longer).

Part of the springtime ritual is pruning the trees. We have 32 trees in our orchard. This last Saturday we pruned the apples. Each tree has a unique pruning strategy and you’ll find that pruning strategies differ between gardeners and a lot of people have to get tree trimmers near Clovis to help them because they’re unsure how to go about pruning and trimming their trees. Here’s a typical apple tree after pruning.


See how the apple looks sort of like an umbrella or perhaps a gnarled old man? The approach we use works well for hand picking. It’s an older technique that many modern orchards have replaced with a technique better designed for picking apples from a truck.

We prune our apples every other year; the off year. Apples produce well one year and then take a bit of a vacation the next year. Yes, we’ll get some apples from our trees, but not as many as on a good year. Of course, prudent canning techniques ensures everything evens out. What sorts of spring delights do you experience? Let me know at John@JohnMuellerBooks.com.


Errors in Writing

I get upwards of 65 e-mails about my books on most days. Some of the conversations I have with readers are amazing and many readers have continued to write me for years. It’s gratifying to know that my books are helping people—it’s the reason I continue writing. Although I make a living from writing, I could easily make more money doing just about anything else. The thought that I might help someone do something special is why I stay in this business. When I actually hear about some bit of information that has really helped someone, it makes my day. I just can’t get the smile off my face afterward.

Of course, I’m constantly striving to improve my writing and I do everything I can to help the editors that work with me do a better job too. Good editors are the author’s friend and keep him from looking like an idiot to the reading public. In fact, it’s the search for better ways to accomplish tasks that has led me to create the beta reader program. Essentially, a beta reader is someone who reads my books as I write them and provides feedback. The extra pair of eyes can make a big difference. Beta readers who provide constructive feedback on at least three chapters receive my thanks in the book’s Acknowledgments and a free copy of the published book. (If you’d like to be a beta reader, please contact me at John@JohnMuellerBooks.com for additional details.)

You’d think that with all the pairs of eyes looking at my books, they’d come out error free. After all, it isn’t just me looking at the book, but several editors and the beta readers as well. Unfortunate as it might seem, my books still come out with an error or two in them. The more technical the topic, the greater the opportunity for errors to creep in. Naturally, the errors are amazingly easy for just about everyone else to pick up! (I must admit to asking myself how I could have missed something so utterly obvious.) When there is an error found in the book, I’ll provide the information to the publisher so it’s fixed in the next printing. The error will also appear on the book’s errata page on the publisher’s site. If the error is significant enough, I’ll blog about it as well. In short, I want you to have a good reading experience so I’ll do everything I can to hunt the errors down and correct them.

However, not every seeming error is actually an error. There are times where an apparent error is simply a difference of opinion or possibly a configuration difference between my system and the reader’s system. I’ll still try to figure these errors out, but I can’t always guarantee that I’ll fix things in your favor. After all, another reader has probably found still other results or has yet another opinion on how I should present material in the book.

The long and short of things is that despite my best efforts, you’ll probably encounter an error or two in my books and I apologize for them in advance. We’ll also continue have differences of opinion and that’s usually the source for new ideas and new ways of viewing things. I’m honest enough to admit that I do need your help in creating better books, so I’ll always listen to you and think about what you have to say. I hope that you’ll continue to read my books and do amazing things with the information you find therein. The results of your researches are truly the reason I remain in this business and I realize that we’re in this together. Thanks for your continued support!


Considering the Move to IPv6

I was getting my technical reading done this morning and ran across yet another article about IPv6 by Woody Leonhard entitled, “Caution: Bumps in the road to IPv6“. One of the main focuses of the article is that you should check your IPv6 compatibility using the features provided by Test Your IPv6 Connectivity. The article also assumes that you have IPv6 installed on your local system if you’re using a newer version of Windows. Of course, most people do have IPv6 functionality on their Windows 7 systems, but what if you don’t? How can you even check for IPv6 functionality?

Performing a local check is relatively easy. Open a command line, type IPConfig, and press Enter. You’ll see a listing of your IP configuration similar to the one shown here:


In this case, you can see that the connections do indeed have IPv6 connectivity. If you need additional information, you can type IPConfig /All and press Enter instead. Of course, the presence of the information doesn’t always mean that the connections are working properly. In many cases, you can fix IPv6 problems by using the IPConfig /Renew6 command. There are separate versions of the command for IPv6 and IPv4—the IPv4 version of the command is simply IPConfig /Renew, so make sure you use the correct version.

The IPConfig utility is good for quick information and fixes. If you want to perform something a little more detailed, you need the NetSH utility instead. For example, if you want to install IPv6 on a machine, you type NetSH Interface IPv6 Install and press Enter. Interestingly enough, you need to simply know about this particular command because it doesn’t appear when you type NetSH Interface IPv6 and press Enter (which shows the other available IPv6 commands) as shown here:


However, you do get a wealth of information from NetSH. Type NetSH Interface IPv6 Show and press Enter to see the entire list of Show commands listed here:


One of the least appreciated and underused NetSH commands is NetSH Interface IPv6 Dump. This command creates a batch script for you that recreates the configuration on the current machine as shown here:


So, if you type NetSH Interface IPv6 Dump > IPvConfig.BAT and press Enter, you end up with a batch file you can use to create a successful configuration on other systems. The Dump subcommand is available in a number of NetSH contexts and you should employ it freely. You can find myriad other uses for NetSH in Chapters 2 and 24 of Windows Command-Line Administration Instant Reference. The IPConfig utility appears in Chapter 9. Let me know about your unique uses for both of these utilities at John@JohnMuellerBooks.com.