4

I have some macros in VbaProject.OTM. Once in a while, I update the code, but the timestamp does not change. I did not check whether the file size changes.

This, this and this report similar observations.

Is this behavior expected?
If not, any idea on what could the problem be?

The first link above shows a couple of workarounds, but I meant to understand the cause for this, and to find a solution to revert this behavior (if possible), instead of workarounds.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

3 Answers3

3

It gets better. None of the "tell me when a file changes" features in Windows, namely FindFirstChangeNotification() and ReadDirectoryChangesW() will report when the file is saved, unless the size changes, and that doesn't happen unless a lot of code is added. I just had to drop in 64 K of comments to get it to change.

procmon shows write operations, but there is no operation to change the time stamp. I don't quite get how they manage to keep the file time the same when the default behavior is to update it every time the file is written to.

This is not just a problem when you want to distribute macros by distributing the file (which you really shouldn't, Microsoft is correct there; the internal structure of the file might change with Outlook versions or even individual updates). It is also guaranteed grief when you reinstall or move computers and find out too late that the copy in your roaming user profile is ancient ...

My personal workaround is to have something in Startup that touches the file. That way, it's always copied.

The cause, btw, is either of the two mentioned at http://blogs.msdn.com/b/oldnewthing/archive/2011/08/12/10195186.aspx. Outlook is using memory-mapped IO, and it may well also do the SetFileTime() thing; I'm not sure if procmon would see that.

Christian
  • 71
  • 1
  • 5
1

None of the following appears to be documented, but based on the experience collected from posts already listed in the OP. More solid information might be posted.

Is this behavior expected?
No. This is quite different from what many people would expect.

If not, any idea on what could the problem be?
It appears that this behavior is standard in Outlook (i.e., not something that I see in my system due to configuration issues). So, the "problem" is how Outlook is designed.

... I meant to... find a solution to revert this behavior (if possible)...
There appears to be none.

... instead of workarounds.
As mentioned here and in the OP.

PS: Since none of the two workarounds proposed appear to be options in some cases, one may try to write a macro that would execute a shell command with touch ... (or the like), to set the modification time. It will likely find that VbaProject.OTM is in use, so one would have to deal with that too. Not a trivial task.

0

From This which you linked to includes two ways to resolve this issue:

  • If you intend to distribute, write a COM Add-in (that has always been the preferred way of distributing macros in Outlook)
  • If you do not intend to distribute and have access to a c# development kit (would not the free version of VSTO work? I haven't tried...) use the three lines of code suggested therein.

Do neither of those work? If not, you might suggest in your question why these methods will not work for you, so that other suggestions may be forthcoming.

David Zemens
  • 53,033
  • 11
  • 81
  • 130
  • I found no trace of this behavior being expected (could you point me where?). Collected comments from the thread: 1) "I guess this is an error, or ....?", 2) *One MVP*: "You're right - it doesn't change. Very strange, I've never noticed this before", 3) "We discovered this little glitch recently...", 4) "I'm sure it's not a bug though. It's an "undocumented feature". We all know that MS's definition of an "undocumented feature" is "a bug with seniority!" :-)", 5) "after 4 years this Problem was reported, MS did not make any correction to this Problem, the failure is still there!!" – sancho.s ReinstateMonicaCellio Jul 18 '14 at 02:15
  • I did find the fragments proposing workarounds, and then I did not ask about it. – sancho.s ReinstateMonicaCellio Jul 18 '14 at 02:17
  • Perhaps I jumped the gun with the "expected"-ness. It may not be expected (I certainly wouldn't expect it, and neither would most people), but the fact remains that if MS has been aware of this for 4+ years and there is yet no patch, there probably won't ever be. So, assume it's an "undocumented feature" :) fact remains there are two proposed answers in that thread alone. Do neither of those work? If not, you might suggest in your question why these methods will not work for you, so that other suggestions may be forthcoming. Cheers. – David Zemens Jul 18 '14 at 02:28
  • Now we agree (I would say it is quite unexpected, and then the question). I was wondering if this is a generalized issue (i.e., everyone has it), or if it arises under some (as of yet undetermined) circumstances. I did not attempt any workaround, perhaps there was a more fundamental one (that was part of the target of the question). PS: I was also wondering why the downvote, maybe I missed something else... – sancho.s ReinstateMonicaCellio Jul 18 '14 at 03:58
  • I see the same thing happen with my OTM file. the 'last modified' date somehow differs from the 'created' date, but changes to the file don't get reflected in its properties. I tried examining using FileSystemObject to be sure. – David Zemens Jul 18 '14 at 13:32
  • PS it won't let me remove the downvote until you edit the Q. If you update with that info from your last comment it would make a better question :) – David Zemens Jul 18 '14 at 13:33
  • cheers. downvote replaced with upvote, it's much more clear what you've tried now and what you're seeking to acheive! – David Zemens Jul 19 '14 at 00:31
  • I do not plan on distributing. It is mostly for "documentation" purposes, including proper backing up. And I do not have access to C# DK. – sancho.s ReinstateMonicaCellio Jul 24 '14 at 17:27
  • Alright. Well what other information would you like* to obtain in order to close this question as "answered". We have identified it as a bug that other people across the world have and continue to experience. There are two solutions/workarounds available which you are not interested in or not able to use. Sometimes the answer is "there is no way to do what you are trying to do." This may be one of those cases. – David Zemens Jul 24 '14 at 17:49
  • Given the case, I meant to wait for some more time before closing. Perhaps someone with more solid info might jump in. So far, we only have as input the links already listed in the OP, sort of mild. I have seen such recommendation a few times (perhaps even in FAQs, I don't recall), and I see it convenient. And for the time being, I added explicit answers to my questions (answers which were partly implicit in the OP, waiting for a more solid rejection or confirmation). – sancho.s ReinstateMonicaCellio Jul 25 '14 at 13:43