Karl`s PC Help Forums Last active: Never
Not logged in [Login ]
Go To Bottom

In memory of Karl Davis, founder of this board, who made his final journey 12th June 2007

Printable Version | Subscribe | Add to Favourites   Post new thread Poll:
Author: Subject: VBA doing stupid things!
LSemmens
Undercover MOD
********


Avatar


Posts: 32767
Registered: 19-11-2004
Location: Riverton, South Australia
Theme: Windows XP Silver
Member Is Offline

Mood: Gone crazy, Back soo

[*] Post 502701 posted on 16-5-2016 at 14:18 Reply With Quote
VBA doing stupid things!



I've got some fairly simple documents that I've created to display a Chord Chart on screen for various songs that I play in Church. So far, so good. Some of the songs need to be transposed to suit either a backing track or the requirements of the vocalists. So far, so good! I've formatted the documents for ease of reading and included the transposition at the appropriate lines on the page so that I can easily switch between the two. I've hundreds of lines of VBA code to automatically format various sections of the the document. On only ONE document This line
Quote:

Selection.MoveDown unit:=wdLine, Count:=4
Fails unless I insert a breakpoint in my code to step through the line. It then works as it should.
As an example this same code is repeated several times in the module to hide/show particular lines. Here is the offending line with the code leading up to it. NOTE: It all works up until this line
Quote:

Selection.MoveDown unit:=wdLine, Count:=2
Selection.MoveDown unit:=wdLine, Count:=1, Extend:=wdExtend
t = HideLine()
Selection.MoveDown unit:=wdLine, Count:=2
Selection.MoveDown unit:=wdLine, Count:=1, Extend:=wdExtend
t = HideLine()
Selection.MoveDown unit:=wdLine, Count:=4

This same code works in all other documents and works if I actually pause the code on that line and step through it, otherwise, all that happens is The selection only moves down one line as though it has hit the EOF, which it most certainly has not.

I'm not expecting any assistance, just having a rant!
View User's Profile View All Posts By User
Katzy
Anything you like
*******


Avatar


Posts: 7564
Registered: 23-7-2002
Theme: Coffee
Member Is Offline

Mood: Fintlewoodlewix.

[*] Post 502709 posted on 17-5-2016 at 09:21 Reply With Quote


Just an off-chance...

Are there enough line to move down by four?
View User's Profile View All Posts By User
LSemmens
Undercover MOD
********


Avatar


Posts: 32767
Registered: 19-11-2004
Location: Riverton, South Australia
Theme: Windows XP Silver
Member Is Offline

Mood: Gone crazy, Back soo

[*] Post 502727 posted on 19-5-2016 at 00:34 Reply With Quote


Sorted it. Just re-arranged the document slightly (managed to merge the line with the one above. I had a sceond one pull the same stunt, so I am unsure what is causing it as the same code is used in hundreds of documents.
View User's Profile View All Posts By User
Post new thread Poll:

Guest Notice
You are a guest, as a guest you can only see a maximum of 3 posts per thread.

If you want to see the rest, please click here to register.