Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2020, 02:48 AM
macropod's Avatar
macropod macropod is offline Macro to highlight alternating sections of a table Windows 7 64bit Macro to highlight alternating sections of a table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,523
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Jennifer Murphy View Post
I'm not sure which code you are referencing.
The code I supplied in post #21.
Quote:
Originally Posted by Jennifer Murphy View Post
In the code I am working on, the keyword parameters can be written in any order. That's the whole purpose of keyword parameters, no?. If they must be in a specific order, there is little need for the keywords. They can just be coded as values:

Parms: 3, 215, 199, 244, 0
That code was based on your original specification:
Quote:
Originally Posted by Jennifer Murphy View Post
Parms: Col=3, Hdrs=0, RGB=215,199,244
and requires each parameter to be preceded by '=' and, except for the last, to be followed by ','. The order in which they occur is critical - regardless of whether you supply the keywords (which aren't actually necessary for the parsing). For example, the code cannot possibly know which is the column and the row if you use:
3, 1, 215, 199, 244
or:
1, 3, 215, 199, 244
unless you stick to a specified order. Yes, you could just pass a string of numbers separated by whatever character you choose (e.g. just a space or a comma) but, even so, the order would remain critical.
Quote:
Originally Posted by Jennifer Murphy View Post
And in my code, all of them have defaults, so none of them are required. I loop through them one by one using a Case statement to determine which keyword it is and then process the value.
It seems you're using something different from what we've discussed. It's a bit hard to develop code if you're shifting the goal posts like that.
Quote:
Originally Posted by Jennifer Murphy View Post
That's an interesting and clever way to do that. At first it looked odd to me, but I see that it avoids having to test for i > UBound at each step and then having a label to Go To or messy nested If statements.

But I've never seen a Case statement coded like that. It's always:
Code:
   Select Case i
      Case 0: C = Trim(Split(Split(StrParms, "=")(1), ",")(0))
      Case 1: StrRGB = Trim(Split(Split(StrParms, "=")(2), ",")(0))
      Case 2: Hdr = Trim(Split(StrParms, "=")(3))
   End Select
It can be coded either way. The only reason for having the loop & select case statement, though, is to cater for:


Quote:
Originally Posted by Jennifer Murphy View Post
I think I'll include the Headers=n parameter. If it's present, I'll use it. If not, I'll check for the Repeat option and use that. If neither are present, I'll assume no headers and start highlighting with row 1
which means one parameter has become optional and, so, a way is needed to test for its presence.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 02-23-2020, 10:26 AM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Macro to highlight alternating sections of a table Windows XP Macro to highlight alternating sections of a table Office 2007
Competent Performer
Macro to highlight alternating sections of a table
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
The code I supplied in post #21.

That code was based on your original specification:

and requires each parameter to be preceded by '=' and, except for the last, to be followed by ','. The order in which they occur is critical - regardless of whether you supply the keywords (which aren't actually necessary for the parsing). For example, the code cannot possibly know which is the column and the row if you use:
3, 1, 215, 199, 244
or:
1, 3, 215, 199, 244
unless you stick to a specified order. Yes, you could just pass a string of numbers separated by whatever character you choose (e.g. just a space or a comma) but, even so, the order would remain critical.

It seems you're using something different from what we've discussed. It's a bit hard to develop code if you're shifting the goal posts like that.
Perhaps I was not as clear as I could have been. Sorry about that. Written discussions are fraught.

Once you showed me how to have a parameter string in the document, it was always my intention to have keyword parameters that could be coded in any order and for all of them to have default values in case no parameters at all are passed.

The general syntax is something like this:

Code:
TblHiLite: [Column=C|1] [Headers=H|1] [RGB1=R,G,B|255,255,255]
           [RGB2=R,G,B|219,229,241] [MatchCase=Yes/No|Yes]
My code handles that by breaking the entire string into tokens delimited by spaces. It then breaks each token into a keyword and value delimited by "=". If the keyword matches one of the defined ones, the value is used.

The order doesn't matter and none of them are required. This is a very flexible syntax and easy for the user (me) to use.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to highlight alternating sections of a table Macro to highlight a list of words bakerkr Word VBA 4 10-19-2017 02:23 PM
Macro to highlight alternating sections of a table Word 2010 VBA Print Macro - Specified Sections Benbon Word VBA 3 03-30-2017 02:31 PM
Macro to highlight alternating sections of a table Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
Macro to highlight alternating sections of a table Macro to highlight words bertietheblue Word VBA 9 07-01-2013 12:39 PM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:26 PM.


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