Archive for March, 2007

Setting Word’s default suggested filename

March 20, 2007

Our company recently moved to use Remedy for bug management and customer support.

One of the things that bothered me the most in Remedy was its inconvenient way of showing issues’ (a.k.a cases) activity history.

So I sat down to write a Word macro that manipulates Remedy windows to get the history data as a flat text and conveniently format it as a Word document. (If you are using Remedy and would like to get this script, leave me a note)

I had several problems in writing this macro, and I learned some more about Word VBA while overcoming them.

One of the problems I encountered was that I couldn’t find a way to control, from the VBA code, what will be the default name of the document when the user first saves it. Word seemed to insist on using Doc1.doc (on Word 2003) or 01.doc (on Word 2007). At first, I left it as an known issue, since I didn’t think this would really hurt anyone. But I got some user that has some more requests from that macro, and he also urged me to solve this problem.

I then realized that Word actually takes the first line to be the file name, so I simply added a header to the file with the details of the issue (removing all special characters which Word sees as delimiters) and this indeed solved the problem.

While writing this post, I search for questions on the web on how this can be done, since I can’t be the only one who needs it, and found that it can be done from script. However, since the header I added actually make the generated document look nicer, I think I’ll leave it that way.

Advertisements

Office Picture Manager and other programs

March 20, 2007

I recently found Microsoft Office Picture Manager, and I must say I’m quite impressed.

For viewing pictures I use IrfanView, and for managing my photos I use Picasa, but from time to time I need some ad-hoc operations on files, and for this, Office Picture Manager does a great job. Here are two examples:

  • I needed to crop faces from some family pictures to put in the profiles my Geni‘s family tree. Cropping was never so easy with Office Picture Manager.
  • I collect screenshots of our customers screens, and some times when they open a case, they send a word document with screenshots. I found that the best way to get an image out of a Word document to a graphic file is simply to paste it in Office Picture Manager.

It takes some getting used to, as it has these side-bar task panes instead of dialogs, but for the kind of work I need it for, it does the work.

Speaking good on Microsoft, I’m feeling quite comfort with their Windows Live Writer, although it is in beta. This is rather surprising, as I usually don’t publish anything nowadays without passing it through Word 2007 wonderful spell checker but since it saves me the hassle of re-introducing the links after copying the edited text, I’m going with it. I hope I don’t make any embarrassing mistakes. I also hope that the Writer team will find a way to integrate it with Word 2007 spell checker. One other missing option is the ability to easily add a category from Writer.

Speaking of Word 2007, I plan to have a post where I list all the good things I found in Office 2007 versus the annoying things.

And finally, speaking of graphics software, I’m in a constant search for a replacement to Picasa. After all, Google doesn’t really know how to build desktop application that pleases developers. They make it too simple with no advanced options (not to mention scripting), and that really annoys me. But the most two features that annoys me are the amazing thing that you don’t easily see what albums a pictures is already related to, and also the annoying but with the keywords auto-completion for non-English languages (can’t find a link right now).

I do like the option to relate each picture to several categories (a.k.a tagging, a.k.a albums) which is not found in every other photo manager. Obviously, Flickr would be the right place to go, but my wife don’t like the idea of having our pictures on the web.

Strange problem on Vista’s Windows Mail

March 11, 2007

Our product contains an ActiveX that is used to create a mail message so the users can easily send custom data from our application.

Our code uses Simple MAPI’s MAPISendMail function to create the message. When it initialize the MapiMessage parameter we always pass the same arrays for the lpRecips and lpFiles members, but only if we need to pass actual recipients or files we initialize them. If not, they are not initialized, but this does not have to be a problem, since we pass 0 in the nRecipCount and nFileCount members.

And, indeed, there was never a problem with it, until our QA started testing our product on Windows Vista and found out that e-mail messages are not created when there are no attachments.

I checked it and found out that MAPISendMail returned MAPI_E_FAILURE which is a general error code with no real explanation. Playing with it some more I realized that the function, for some reason, looks into the lpFiles array, even though the nFileCount member is 0.

The fix was quite simple – pass a null pointer when nFileCount is 0, but this seems like a plain bug.

BTW, although I don’t plan to install Vista in the near future after what I’ve heard about it, I was really impressed with some of the small UI improvements in Vista’s File Explorer, and might give it a second thought in the not-so-near future.

httpd.conf location

March 6, 2007

From time to time I find myself having to debug a UNIX machine that runs apache, and I have to figure out where its httpd.conf is located. I usually look around the location of the executable and find it, and I always assumed it is actually somehow set in the appropriate environment variable, but today Shirley, a colleague from QA called me and asked for help in finding the httpd.conf file used by the apache she was running on her AIX test machine.

A quick qoogling told me that unlike what I thought, the apache documentation clearly says that the location of this file is set at compile time, but can be overridden using the –f option. But how can I know what is the location that the server was compiled with?

Reverting to search Google Groups helped me find out that I can use the “httpd -V” command to get the options that the httpd executable was compiled with. One of these options is the SERVER_CONFIG_FILE, which will tell you the exact path of the httpd.conf that this apache server is using by default.

"Display Anchors" toolbar button

March 6, 2007

I often use the “Display Anchors” option found in the Information menu of the Web Developer Firefox extension to build a link directly to a part of a page I’m interested in.

I usually doing it by clicking the toolbar button to show the Web Developer toolbar, then open the Information menu and select “Display Anchors”. A shorter way might have been using the right-click menu, since all Web Developer options are also available through a right click menu item. In any case, it requires at least three steps – Web Developer -> Information menu -> Display Anchors for this simple operation.

Today I’ve got sick of it and looked for a way to make it a one click operation. I googled for “display anchors” toolbar Firefox and got to David McRitchie’s bookmarklets page, where as point to the no-longer-available Show Classes and IDs bookmarklet page, but also has his own “id visible’ bookmarklet, which does something similar:

javascript:(function(){ var z=[],N,id,tc,j; function r(N) { if (N.id) z.push(N); var C=N.childNodes,i;for(i=0;i<C.length;++i)r(C[i]); } r(document.body); for (j in z) { N=z[j]; id=document.createTextNode(” %C2%ABid=”+N.id+”%C2%BB”); tc=document.createElement(”span”); tc.style.color=”red”; tc.style.background=”#FFEE99″; tc.appendChild(id); N.parentNode.insertBefore(tc,N.nextSibling); N.parentNode.insertBefore(document.createTextNode(” “),tc); }})();

I worked on it a little, and came up with a bookmarklet that creates link in a fashion similar to Web Developer’s “Show Anchors” way:

javascript:(function(){ var z=[],N,tc,j; function r(N) { if(N.id) z.push(N); var C=N.childNodes,i;for(i=0;i<C.length;++i)r(C[i]);}r(document.body);for(j in z) { N=z[j];tc=document.createElement(”div”);tc.innerHTML=”<a style=\”background-color:#FFFF99 !important;border:solid 1px #FFCC66 !important;color:#000000 !important;opacity:0.9 !important;text-decoration:none !important;font-size:10px !important;\” href=\”#”+N.id +”\”>#”+N.id+”<a>”;N.parentNode.insertBefore(tc,N);}})();

It currently only add links to elements with ID and not to a href-less named <a> elements. I’ll add these when I see the need.

Note: The bookmarklets are currently not links as I can’t find a way to convince WordPress editor to make them proper links.