DeadKing
10-27-2011, 07:03 AM
Hi.
I know that computer program can not cheat, but my macro does! :banghead:
I have lets' say 10000 lines of text. I wrote some macro which (among others things) delete some parts of this text as they are useless for me. The macro seems to work almost perfectly. Almost.
Among those 10000 lines are parts (6-8 lines) I want to delete. In the middle of this part is static text (same word in every part in whole text).
So, I Selection.Find.Execute this static text, move cursor 3 lines up (static position), check if I can delete and delete line by line this part of text. When I find text which is not to be deleted I Exit this loop and move to next Selection.Find.Execute
Now how I know my macro cheats - in random parts of text (in test it happens 2-5 times per macro run) the static text is detected, everything under this static text is deleted exactly as it should be. But the static text and those 3 lines befor it remains in place.
BUT - when I try to debug this part of code, going step by setp, line by line trough my code, the macro deletes everything as it should. Therefore I'm not able to find out what cause the problem.
An interesting thing about this "cheat" is that macro usualy skips same pieces of text. Lets say I want to delete lines 5,6,7,12,13,14,21,22,23,30,31 and 32, there is good chance I end up with deleted 5,6,7,14,21,22,23,30,31 and 32. (12 and 13 skipped) But of course, if I try step by step debug, it will delete 5,6,7,12,13,14,21,22,23,30,31 and 32 as it should.
Another thing I've noticed (and I'm not sure if it have anything to do with this problem) is that after some listing (Page Up/Down), my cursor disappear and appear again after writing a thing or after some time. (if it disapper on line 3451, I can write and delete a character or just list a bit more and on 3524 it appears again (example)).
Have anyone of you ever experienced this? Can anyone help me out?
I know that computer program can not cheat, but my macro does! :banghead:
I have lets' say 10000 lines of text. I wrote some macro which (among others things) delete some parts of this text as they are useless for me. The macro seems to work almost perfectly. Almost.
Among those 10000 lines are parts (6-8 lines) I want to delete. In the middle of this part is static text (same word in every part in whole text).
So, I Selection.Find.Execute this static text, move cursor 3 lines up (static position), check if I can delete and delete line by line this part of text. When I find text which is not to be deleted I Exit this loop and move to next Selection.Find.Execute
Now how I know my macro cheats - in random parts of text (in test it happens 2-5 times per macro run) the static text is detected, everything under this static text is deleted exactly as it should be. But the static text and those 3 lines befor it remains in place.
BUT - when I try to debug this part of code, going step by setp, line by line trough my code, the macro deletes everything as it should. Therefore I'm not able to find out what cause the problem.
An interesting thing about this "cheat" is that macro usualy skips same pieces of text. Lets say I want to delete lines 5,6,7,12,13,14,21,22,23,30,31 and 32, there is good chance I end up with deleted 5,6,7,14,21,22,23,30,31 and 32. (12 and 13 skipped) But of course, if I try step by step debug, it will delete 5,6,7,12,13,14,21,22,23,30,31 and 32 as it should.
Another thing I've noticed (and I'm not sure if it have anything to do with this problem) is that after some listing (Page Up/Down), my cursor disappear and appear again after writing a thing or after some time. (if it disapper on line 3451, I can write and delete a character or just list a bit more and on 3524 it appears again (example)).
Have anyone of you ever experienced this? Can anyone help me out?