Category Archives: Troubleshooting

Phantom Header Changes in Word

0
Filed under Office, Troubleshooting

For today’s blog entry, I’m going to delve into a bit of Word esoterica that, if you’re into this sort of thing, you might find fascinating, and if you’re not, well, you have been warned<g>.

If a document is changed in Word, you’d expect to get a prompt when you close the document, wouldn’t you?

Well, that’s apparently just expecting too much, my friend.

And if you were to load a document programmatically and simply iterate through it, without changing anything, you’d expect that the document wouldn’t actually change, wouldn’t you?

Well, that’s also… oh, you get the picture.

It appears to be possible in Word, without programming, to create a header that doesn’t actually exist, or rather, that exists but is completely empty.

If you then iterate through the headers of the document, retrieving the Range of each, the act of simply “retrieving” the range, not actually modifying it, will cause the header to be modified, inserting a paragraph mark where there was none before.

This can effectively shift the entire document down, since, in the original document there was no “paragraph” in the header, but now there is.

Even more interesting, this modification isn’t logged internally by Word, so if you were to close the document, you get no prompt that a change has been made, and from what I can tell, the change isn’t actually saved, although it’s very visible on-screen.

You can test this by creating a document with a null header, then, adding this VBA code and running it:

Sub Test()
   Dim sct As Section
   Dim r As Range
   Dim hdr As HeaderFooter
   
   For Each sct In Me.Sections
      For Each hdr In sct.Headers
         Set r = hdr.Range
      Next
   Next
End Sub

How do you create a document with a null header? To be perfectly honest, neither I nor a Microsoft Tech could figure that one out. Please let me know if you can.

But what I did discover was that the situation yielded something you could detect.

Essentially, the problem is this:

Each SECTION object in Word has a PAGESETUP object associated with it.

And each PAGESETUP object has an associated HEADERDISTANCE and TOPMARGIN property. It also has FOOTERDISTANCE and BOTTOMMARGIN properties, but I’ll only deal with headers here. Footers are handled in exactly the same way.

In a document’s section, if the HEADERDISTANCE is ever >= the TOPMARGIN, any changes in the size of the header have the potential for “spilling out” over the limit of the margin and pushing the content of the section body down.

I say potential, because if the header doesn’t contain anything, or if what it contains is not enough to push the bottom of the header past the TOPMARGIN, everything will stay put and all will be well.

In any case, right before you save the document, you simply need to iterate through all the headers in all the sections of the document and test if they’re empty. If they are, you force the HeaderDistance back to half of the TopMargin.

Section.PageSetup.HeaderDistance = Section.PageSetup.TopMargin / 2

Why half? It essentially doesn’t matter what it is, as long as it’s less than the TopMargin.

But what makes up an “empty” header?

Once you get the Range of the header

set Range = Header.Range

Make sure it’s not a linked header

If Range.LinkToPrevious then {it's linked so don't bother with it}

and then check the character and word counts

If Range.Characters.Count > 1 and Range.Words.Count > 0 and Range.Characters.Count > Range.Words.Count Then
   {this is NOT an empty header}
End If

If it’s empty, adjust the HeaderDistance as noted above.

Fun stuff.

KB938194, Beware!

2
Filed under Troubleshooting, Vista

This Vista Update, delivered 9/4/07 at about 3am (for one machine, anyways) has some serious issues, so beware.

Now, when I load Word 2007, if I immediately quit Word, it crashes. And if I attempt to load a document by dbl clicking on it, Word fails to load the document completely, just opens an empty window. Even odder though, is that I have a different machine that I pulled the update earlier for (it’s set to manual update) and it’s fine.

The only difference between the two that I can see, is that on the failed machine, Word was OPEN at the time of the upgrade.

Even worse, UNDOING the Patch caused the machine to fail to boot. It would start to boot up, then just shut down.

I had to use the “Boot to last known valid configuration” option, then use the System Restore Point function to rewind back to before the 3am patch.

Once I’d done that, everything ran fine again.

Ah the joys of automated updates.

Network Autotuning and Vista

2
Filed under Troubleshooting, Utilities

I’ve noticed over that past few weeks of running Vista that certain things tend to be A LOT slower now, even given the fact that I recently picked up a gigabit network card for my server, and a gigabit switch, so I could make use of the built-in gigabit network adapter on my new workstation motherboard.

For instance, I use a program called VBLiner to line number all my VB source right before I compile it. The line numbering process itself is very fast, but the program would pause, noticeably, for each file it opened. It was almost as if the process of locating and opening the file was slow, but actually reading it was very fast.

Today, it finally got to be too much, so I had to start digging.

Come to find out, Vista has this nifty new thing called “Network Autotuning” that, apparently, doesn’t work particularly well.

You can see it yourself by opening a DOS box (with Admin priviledges), and entering

NETSH INTERFACE TCP SHOW GLOBAL

You should end up seeing something like this:

image

That “normal” is the problem.

Execute this to turn off autotuning:

NETSH INTERFACE TCP SET GLOBAL AUTOTUNINGLEVEL=disabled

turn it back on with

NETSH INTERFACE TCP SET GLOBAL AUTOTUNINGLEVEL=normal

and, apparently, using this will sometimes work, too, though I’m a bit hesitant to bother at this point.

NETSH INTERFACE TCP SET GLOBAL AUTOTUNINGLEVEL=HIGH

Nothing like a built-in network performance de-tuner.  It’s STRESS.EXE but without all the hassles of actually having to run a utility. Grrr.

BOOTMGR is missing

0
Filed under Hardware, Troubleshooting

So I’m getting all set to upgrade my TIVO harddisk. I’ve downloaded and burned MFSTools, gathered all the various bits together, etc.

I thought, Hey, it’d be a good idea to try this out on a scratch HD first, just to make sure I know what I’m getting into.

So I grabbed an old 120GB drive, swapped it into my machine, and was going to reformat it as FAT32 and copy a few files on it, so act as a surrogate TIVO drive.

I swapped the drive in, restart the machine….

BOOTMGR is missing

Huh!??????

After some panicked Googling from my server, I discover that Vista has a nasty habit of writing the BootMgr sector to the “first” HD in the drive sequence according to how your BIOS is configured at the time you install Vista.

In my machine, the RAID comes pretty late in the boot sequence, so apparently, my spare 320gb drive that I was intending to use in my TIVO inadvertently picked up the Vista boot manager.

To avoid this whole mess in the first place, make sure when you install Vista, the ONLY HD that’s installed is the one you’re installing Vista onto.

However, if you’re like me, that’s not much of an option. Which leads to solution #2:

  1. Shut the machine down.
  2. Disconnect any “other” hd’s (other than the one that has Vista installed). If you’ve got a RAID, leave only those drives in the RAID connected.
  3. Find your Vista Boot DVD
  4. Put it in and restart, boot to the DVD.
  5. The Vista installer will start up and ask if you want to install in English, etc. Click Next. This won’t actually start installing Vista.
  6. The next screen, towards the bottom, has a “Repair your computer” option. Click it.
  7. Click the operating system installation (there’s likely only the one Vista installation listed). Click next
  8. In the System Recovery Options dialog, click Startup Repair.
  9. Restart the computer.

Worked for me.

Outlook and Attachment Strangeness

0
Filed under Office, Troubleshooting

Dealing with attachments in Outlook is a bit like entering an Ultimate Fighting match against a professional half-octopus, half-eel. It really doesn’t matter what style of fighting you choose, the octo-eel is guaranteed to take you down more than once in the match, and there’s really no telling whether you have a chance at winning.

An app that I’m working on deals with attachments in Outlook, more specifically, it deals with Office format attachments, so we’re talking about DOC, XLS, and PPT files (and about 2 dozen other *X and *M formats introduced in Office 07).

Anything else (like BMPs, TXT files, etc) are supposed to pass on through like yesterday’s iceberg salad.

However, astute customers noticed that, in some cases, the order of the attachments could change at times. If you had numerous attachments to your email, and you intended on them being in a particular order, that might not go over well.

Now, you might think, with such a nicely laid out object model as Outlook’s, that preserving the order of attachments in a message would be trivial. Hell, you might even thing you could simply replace one attachment with another, simply by using a replace method or somesuch.

And you’d be wrong.

There’s no replace method, unlike GroupWise. And the ATTACHMENTS.ADD method doesn’t allow you to specify an ordinal. It does allow you to specify a position, but that value is only used to indicate the character position of the attachment in an RTF format email. If the email format is plain text, or HTML, the position isn’t used at all.

Then there’s this jewel from the MSDN documentation on the add method.

To ensure consistent results, always save an item before adding or removing objects in the Attachments collection of the item.

Special.

Add to all of that the fact that Word can also be used as the email editor (albeit in approximately the same capacity as the built-in Outlook RTF editor from what I can tell), and you have a whole lot of arms to fight with on this octo-eel.

The bottom line however, turns out to be relatively simple.

  1. First, you have to make a single pass through all the attachments in a message and for every one you plan on removing, you need to add the new one. In addition, for those that you don’t plan on removing, you have to extract them, then add them again anyway, in the same order as they already exist.
    This will cause the email to end up with a double set of attachments; the originals, and all the new ones, plus a second copy of any original attachments you didn’t necessarily want to mess with but have to anyway.
  2. Next, make another pass through all the attachments, removing all of the original attachments, but leaving everything else. Now, the email will contain the proper list of attachments, both new and untouched originals, in the original order, at least for plain text and HTML formats.
  3. For Rich Text, there’s one more trick….
  4. When you add the new attachments (or re-add those attachments you intend to pass through, in step 1 above), retrieve the POSITION of the attachment first.
    If it’s 0, make sure you add the new attachment WITHOUT specifying a position argument. Specifying a 0 for the position will only mess things up.
    If it’s NOT 0, however, add the new element with a position argument of the original POSITION + 1

It sounds more complicated than it is.

If you get any part of it wrong, you’ll know pretty quick. Usually, the attachments will end up in the sent email reversed in order. Worse case, some will end up missing.

One final trick. Testing all this can be a real pain, but you can make it a little easier.

Set up Outlook with POP accounts only (don’t use Exchange for this). Then set it to NOT send email on startup:

image 

Anything you send will end up in the outbox, where you can examine it, use it for debugging, drag it back to the inbox to attempt a resend, or delete it. And from what I can tell, whatever ends up in the outbox is what would go. There’s no additional processing done after that.

Plus, you don’t even have to use a legitimate TO address, anything that looks like an email address will work.

Believe it or not, I actually like Outlook, despite it’s, uh, quirks? It’s been my email system since about 97. I’ve never had a corrupted PST file, never lost an email (that I didn’t unintentionally delete with Shift-Del), and never gotten an email-born virus.

Now, excuse me, I have some serious knocking to attend to. 

Flying Model Simulator and Vista

4
Filed under Helicopters, Troubleshooting, Vista

Apparently, DirectX supports something called “retained mode”. Not exactly sure what it is or what it does.

But I just found out that one of my favorite apps, Flying Model Simulator or FMS requires it and you get a lovely dialog that “D3DRM.DLL cannot be loaded” when you install the latest FMS 2 Alpha 85

A little digging and it seems this is quite the problem with a number of older DirectX programs. I suppose MS figured that if the app is more than a few years old, nobody would possibly want to use it anymore:-(

Anyway, this forum posting discusses the problem and pointed me to the Dell web site here to download the missing file.

Copy it to my fresh and shiny clean System32 folder and I’m flying my simulated RC heli again.

image

Here’s something interesting. If I switch windows away from FMS, it pauses in the background, which is actually quite nice.

I don’t recall it doing that under XP.

Something to actually like about Vista? I…feel….so….dirty…. 

Citrix Connection Error

3
Filed under Telecommuting, Troubleshooting, Utilities

I’m now in full rebuild mode after last weeks unfortunate RAID incident.


After installing Citrix Desktop and setting all my parms back up, I got


“The desktop you are trying to open is currently available only to administrators. Contact your administrator to confirm that the correct settings are in place for your client connection.”


After some digging around, I came across this Citrix posting that was exactly the problem.


I had the Citrix Connection set to “Server”, it needs to be “Published Application”.


Too bad the error message itself didn’t actually mention that. But it’s hard to find too much fault in that.


 

RAID Fun

2
Filed under Hardware, Troubleshooting

So ages ago, in internet time (or 9 months ago in real time), I set up a brand new machine, specifically for development with VS2005 and ASP.NET (because, well, it takes a dual core 2.66ghz, 4gb ram beast to be able to write a text file without your keystrokes backing up, but that’s another story).


I’d set up a RAID 0 (that’s striped), mainly for the added performance, which was pretty staggering. My intention was to pick up a couple more drives later and round it out to a RAID 0+1 (which I have in my server, protecting all my actual source, etc).


Anyway, a drive died, quite prematurely, and my machine is thus rendered a doorstop.


I sent off the RMA to replace the dead drive (still under warranty), and picked up 2 more to round the RAID out.


Then I discovered that the Gigabyte GA-965-DS3, otherwise a totally bad-ass mobo, doesn’t actually do raid 0+1. It only supports a 2 drive raid, either RAID 0 or RAID 1. Doh! Tip to manual writing guy: Don’t say things like…



Before you begin


Please prepare


1) At least two SATA Harddrives…If you do not want to create a RAID, you can only prepare one harddrive.


…”


That is a quote directly from the manual.


In my book, the implication there is that you could use more than 2 harddrives in the RAID. Unfortunately, such is not the case.


So I went off to the local computer store and picked up a PCIE 4 port SATA II RAID card, thinking I’d slap it in and be done.


Nay, spoketh St. Ignacious PCMCIA of the holy hardware. That card is PCIE x4, and my Gigabyte motherboard only has 3 completely unused PCIE x1 slots.


Back to the computer store.


I could get a PCI SATA II RAID card, but SATA II drives can pump 3Gbps, whereas a PCI slot can only manage about 266MBps. Does seem right to build up a smokin’ machine, then force it to breath through a pixie stick.


Ok, new mobo time.


Looks like the Gigabyte GA-965-DQ6 has all the bells and whistles, plus the right combination of RAID, PCI slots, ATI Crossfire compatibility, USB and Firewire, plus, it even has a serial port on the backplane, just right for hacking X10.


Note to self: Don’t bother “presetting” up a harddrive that you might want to mirror in a RAID later. Both the Gigabyte built in RAID and Window’s software RAID (via “dynamic disks”) want to obliterate any disk they RAIDify.


The nice dedicated RAID cards (like the Promise Fasttrack), I believe can handle that. Hell, one I was reading specs on seemed to imply it could convert, on the fly, between RAID 1, 0, 5 or 0+1, provided you have enough free space. Now that’s a good time!

Never joke about Hardware problems

2
Filed under Hardware, Troubleshooting

A few days ago, I posted light-hearted jab about some computer problems on the ISS. Well, never one to walk away from an opportunity, karma visited yesterday with no less than a complete failure of one drive in a RAID 0 I have on my main workstation.
For those that have never run RAIDs, it stands for “redundant array of inexpensive disks” and you can run several different configurations.

  • RAID 0 – striped, 2 drives contain various pieces of files, such that you get double performance because both drives can be busy writing and reading different pieces of the same file at the same time. You get almost twice the performance and still have access to the full capacity of both drives.
  • RAID 1 – mirrored, 2 drives contain exactly the data between them. Speeds up read performance, and provided an online backup of data. You have 2 drives but the effective disk space of just 1.
  • RAID 0+1 – striped and mirrored. Best of both of the above.
  • RAID 5, 6 etc – Even better but typically requires higher end dedicated RAID cards.

I had set up a RAID 0 for performance, intending to add 2 additional drives and mirror the setup later, for fault tolerance.
Well, later didn’t come quickly enough, it seems, and one of the less than 9-month-old Western Digital WD3200KS drives (sweet drives, BTW, unbelievably quiet and cool running), went belly up way before its time.
So, I’m filling out RMAs to return the dead drive and ordering two more to complete the full RAID 0+1 setup.
A question for anyone who’s ever done this before. Can I setup a striped RAID 0 now, and add the 2 additional drives later to convert it to a mirrored/striped RAID 0+1 later, when the 2 drives come in, or do I have to have them all in place when I create the RAID initially?
Haven’t had much luck finding an answer online.