Previous Thread:   Working with New Email event in Outlook using VBA

9/27/2005 2:56:00 AM    corrupt OTM file/project
hi  
  
I have rpeivously posted her asking about how to recover the code from an  
  
OTM file that won't start in Outlook VB editor.  
  
To be honest I am activelly looking for a solution since there was a lot of  
  
code in it, and without any notice, the VB editor stopped working.ยด  
  
Currently I am very disappointed at MS because of their lack of support for  
  
this kind of problem. We, in our company, are seriouslly reconsidering our  
  
investment in MS products that we had palnned for the near future and  
  
honestly I do not know what to think or expect.  
  
Does anyone know a way to repair or retrieve code from an OTM file??  
  
Thank you very much  
  
Pedro R.



9/27/2005 5:16:56 PM    Re: corrupt OTM file/project
Hi Pedro,  
  
I dont have a solution to your problem but I have experienced something  
  
similar.  In Outlook 2003 it appears when Outlook hits some code it  
  
does not like that it will produce that lovely message box giving you  
  
the impression that the OTM is corrupted rather than letting any  
  
error-handling in the code manage it.  I havent managed to work out the  
  
rogue bit of code that is causing my problem but I did manage to export  
  
out all the code from the OTM file by right clicking on each object and  
  
selecting "View Code", then copy and paste to a text file using  
  
Notepad.  
  
The problem with this is that the code you are viewing/saving could  
  
contain the bit that causes the apparent corruption (if you saved prior  
  
to running).  So if you can remember the last bit of code you added/and  
  
saved just prior to the problems beginning, you probably have a spot to  
  
start looking or at least remove and see if the corruption continues.  
  
The process I ended up following (as I had changed and saved quite a  
  
number of modules and forms immediately prior to the problem) was to  
  
copy and paste section by section back into a new OTM file and run it.  
  
Several more times I had the "corruption" message so I had to start  
  
again and build up modules piece by piece.  I still havent worked out  
  
what caused the problem but I am happy to say my OTM file is working  
  
fine.  Which would probably mean I havent rewritten the problem code  
  
again, or have written it in a way the 2003 likes.  
  
2003 products seem to produce this message when they cannot handle  
  
certain code.  2003 seems to be a lot tighter in the way code (had  
  
these problems in Access and Excel) can be run but its disappointing  
  
that the latest version does not seem to be able to handle errors as  
  
well as previous versions.

9/28/2005 1:52:38 AM    Re: corrupt OTM file/project
well to give you an update on the current situation: I have already tried  
  
loading outlook/vba with different security settings but with no success.  
  
Also I have opened the OTM file in Wordpad but code is almost  
  
unrecognizable.  
  
It seems to be in some kind of binary form with all the code messed up.  
  
I find very strange and worring that Microsoft does not have an utility to  
  
export code from OTM files since they are saved in a binary format.  
  
Also, it is surprising for me that at least since VB6 all the code was saved  
  
in TEXT files (with binary frx files only for images, etc) and for VBA it  
  
uses a binary format.  
  
I myself have come across with a corruption problem in a vb6 file some years  
  
ago which was easilly solved.  
  
I can not understand why Microsoft, having released and improved office so  
  
many times, makes a release that "goes back" a lot in terms of automation in  
  
the program itself.  
  
We have given up buying upgrades for Office 2003 from microsoft for our  
  
entire company after this episode.  
  
If Outlook can not be automated then it has no advantage over any other free  
  
alternative, at least from our perspective/needs and in the end it's only MS  
  
loss.  
  
I was not expecting this. I am part of the VS 2005 Beta 2 evaluation program  
  
and I must say it's an excelent platform, far beyond Java and any other tool  
  
i've worked with already and this is honestly not to be expected from them.  
  
I'll keep looking for a solution but I'm preparing myself to write all from  
  
scratch again since we did not keep "exported" backups of the OTM file. Only  
  
the OTM itself.  
  
I hope my experience can be of any value to someone considering development  
  
investment in Outlook 2003.  
  
Thank you  
  
Pedro  
  
"Pedro CR" <pramilo@n0.spam.sapo.pt> escreveu na mensagem  
  
news:eBQucawwFHA.3860@TK2MSFTNGP09.phx.gbl...

9/28/2005 4:03:57 PM    Re: corrupt OTM file/project
Pedro,  
  
I think I have located the problem I am having.  It seems to occur when  
  
I reference a "WithEvents" variable from outside the  
  
"ThisOutlookSession" module.  Although they are stated as "Public" they  
  
do not seem to work very well.  
  
The code breaks saying the object is not set.  If I attempt to stop it,  
  
it does not stop and the code continues to run.  It then says its "not  
  
responding" so I close Outlook down and upon opening it again I get  
  
that lovely message that something major error has occurred and do I  
  
want to send a report to Microsoft.  
  
I know it doesnt help your problem but thought others might get some  
  
value from this.

9/29/2005 1:19:46 AM    Re: corrupt OTM file/project
thank you very much for your feedback  
  
I had indeed one module which referenced a WithEvents object just like  
  
yours.  
  
What I find intriguing is that it worked fine for some time.  
  
My problem began because I had digitally signed the macro and later I  
  
removed the digital signature from the Security Dialog box in Outlook.  
  
The next time the macro was run (as part of a New Mail rule), it asked me to  
  
trust the digital signature, the the macro run a couple of times for two new  
  
messages and then failed for the reamaining new messages..  
  
From then on no more Macro.  
  
To tell you even a more funny story, I have already rewritten all of the  
  
code, but this time in a VB6 program (that gets a reference to the running  
  
instance of outlook) and then created a new macro that simply called the  
  
external VB6 program and passed the MessadeID as a command line argument (so  
  
that we could find the message inside the VB program).  
  
Sadly, this run fine but when I restarted the computer all the code was gone  
  
AGAIN !!!!!!!.  
  
I installed the new SP2 for office 2003 and after restarting, I started  
  
getting the same message again "File not found".  
  
I guess it's one thing to have a malfunction once, but this happening TWICE  
  
is too much.  
  
As of this point I find this UNBELIEVABLE. I already checked my hard disk  
  
for bad sectors but it seems ok... so it's not a hardware failure.  
  
The only time I can recall such kind of situations was with DOS and floppy  
  
disks that would go bad again and again. I though we were over that but  
  
perhaps I was wrong...  
  
Good luck for your project.  
  
If you are also having this kind of problems, you should look into  
  
developing the code as an Outlook Add-in or even better a VS2005 managed  
  
Outlook add-in.  
  
I have been coding with vs 2005 beta 2 and I must say it's absolutelly  
  
wonderfull. When I think that MS is already way ahead of the competition I  
  
find new great features again and again.  
  
best regards  
  
Pedro  
  
"Greg J" <frog66@flashmail.com> escreveu na mensagem  
  
news:1127948637.317979.46630@o13g2000cwo.googlegroups.com...