PDA

View Full Version : UseOf: Execute Findtext wildcards



DarkSprout
05-08-2008, 11:21 AM
I've writen a procedure which enables me to Document Code within a .doc
It scans through all Selected Code, changes it to "Courier New" Font.Size 8, Font.Color Blue, and then all VBA KeyWords DarkRed.

The problem I have is with Comments

I'm usingCOMMENT_TEXT = "'[!" & Chr(34) & "]*\" & vbCr
...
Do While .Execute(Findtext:=COMMENT_TEXT, MatchWildcards:=True, Forward:=True, MatchCase:=True) = True
r.Font.Color = conCOMMENT
r.HighlightColorIndex = conCOMBACK
Loop ... Which finds all comments - no problem.
The error is that any string which contains an ' {Chr(33)}
i.e.
strString = "The is in 'Quotes' For Your Information"
becomes...
strString = "The is in 'Quotes' For Your Information"
Colour coding the string wrongly.

Can anybody help me with the Wildcard Expression please.
=DarkSprout=

OTWarrior
05-12-2008, 04:10 AM
Without looking at the full code, couldn't you do a check to see if the line containing ' has a " before it?

puesdo explaination code:

find '
find "

if find ' = true then
if find " = false then
highlight line
end if
end if

end find
end find

hope that helps, although I haven't used wildcards for this purpose, so wouldn't be able to test it.

DarkSprout
05-21-2008, 03:01 AM
Sorry, the above is nonsense in regard to wildcards - can anybody please help!

=DarkSprout=

OTWarrior
05-21-2008, 10:51 AM
Without posting full code, how do you expect anyone to be able to fully understand what you are trying to do?

Also, if someone tries to help you, saying their response is complete nonsense is extremely rude, and I doubt would encourage more people to help you.

I have recently thought of a way this would work, but am now reluctant to help you, so good luck with dealing with your problem on your own, you ungrateful sod.

fumei
05-21-2008, 11:52 AM
I am inclined to agree, as:

"I've writen a procedure which enables me to Document Code within a .doc
It scans through all Selected Code"

seems (as it gives no expanation whatsoever...what the heck does "Document Code within a doc" mean??? Why is document code Capitalized? What does Selected Code mean? Why are they capitalized)...well, like nonsense.

gwkenny
05-21-2008, 06:25 PM
While I do not believe you need to post the whole code, you need to be more forthcoming with your problem.

You say you are changing your font code to blue, VBA Key Words to dark red, then what is the green from?

Is green the font color conCOMMENT? If so, you do not say so, and one must infer. If it is not, where is the green coming from? Is it the default font?

Taking a look at your search string that evaluates to:
'[!"]*\

If this is the case, then: 'Quotes' For Your Information"

Satisifies the condition assuming that there is a backslash (\) character anywhere further on in the document cause you have an * wildcard. Then the string I cited and anything thereafter till the backslash would have the color and highlight indicated in the code. That part is pretty straightforward.


On a side note, belittling someone who is actually trying to help by claiming their information is "nonsense" does not help your cause. Even the best of us read things wrong sometimes AND your post was not the most clear. I think I understand the problem, but I had to make inferences. Only someone with good knowledge of VBA and who took the time to actually work out what you've shown and the possible logic behind the code not shown could begin to even make a guess.

Have a better day!

fumei
05-22-2008, 09:55 AM
You are so diplomatic!

lucas
05-22-2008, 10:39 AM
I am going to weigh in here also. I agree with every responder to your question. You have not provided enough information and when you respond to an attempt to help you despite that fact with a condescending statement you can not expect folks to jump to your aid.

We take pride in the friendliness of our forum and we expect you to be courteous. It is not too much to ask considering that you are here seeking free help from people who are just being generous with their knowledge.

If you wish to crack the whip or yell at someone for what you consider to be incompetence then hire someone.