Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 10-21-2022, 02:59 AM
WordUser789 WordUser789 is offline Macro is manipulating item in wrong section even though variable watch says it should be right Windows 10 Macro is manipulating item in wrong section even though variable watch says it should be right Office 2016
Advanced Beginner
Macro is manipulating item in wrong section even though variable watch says it should be right
 
Join Date: Jun 2017
Posts: 32
WordUser789 is on a distinguished road
Default

Wow, that is super interesting. Thanks for taking the time to reply.

I am guessing that the expected output of that macro would be that it logs each image from the start of the document to the end? For extra clarity I gave all my images alt text describing which one it was, and also added in a line to delete each one as it went for more visual effect. I then stepped through it bit by bit and watched it and wow, no logic at all to it.

1 1 5 Section 5 RH
1 1 6 Section 6 First Page BG
1 1 2 Section 2 BG
1 1 5 Section 5 LH
1 1 6 Section 6 LH
1 2 3 Section 3 RH
1 2 1 Section 1 BG
1 3 6 Section 6 RH
2 1 3 Section 3 LH

I ran it again and the order was the same so it's obviously not random, but thought perhaps it simply runs through them in the order in which they were inserted? With that in mind I made a new document and pasted each graphic in order. Ran it and got this:

1 1 4 Section 3 RH
1 1 6 Section 6 FP BG
1 1 1 Section 1 BG
1 1 4 Section 3 LH
1 1 6 Section 6 LH
1 2 5 Section 5 RH
1 2 2 Section 2 BG
1 3 6 Section 6 RH
2 1 5 Section 5 LH

So, still not in any particular order. It's almost but not quite the reverse order to before, but as it's not exact I won't read much into it.

Anyway, I went back and took out the delete line, and noticed that it ran 6 times through the document. I was puzzled by this but then saw, aha, I have 6 sections. Added another section and it ran through the loop 7 times. So that would indicate that it does indeed see every image as being part of every section, and it loops through them each time. When I had the line in there to delete the image after it printed the info it obviously only found the info once.

Also, the first number is the section number, and it's seeing all bar one in section 1 as opposed to 1-2 per section as is the reality.

Thanks also for sharing your workaround: sounds like that might solve the problem by approaching it from a different angle.
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Footnote numbering wrong after section break peterbav Word 1 03-17-2020 11:18 PM
Macro is manipulating item in wrong section even though variable watch says it should be right How do I make a checkbox or dropdown item reference data in that specific section of the data array? dhare Excel Programming 2 02-24-2016 12:36 PM
Macro is manipulating item in wrong section even though variable watch says it should be right Copying data related to one item to worksheet with many instances of the same item nmp13 Excel 3 02-06-2016 02:13 AM
Multilevel Numbering wrong after Section Break Kay Wood Word 2 01-16-2013 08:44 AM
Help with VBA macro - Variable input sc30317 Excel Programming 0 08-31-2011 01:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft