I am trying to write a word macro that scans the documents and highlights all the numbers that are less then .95
is this possible to do using a word macro?
i guess i really only need the command that selects a range of numbers.
like if number < .95 or something like that. i am not really a vba person and am used to writing only c++ and python scripts.
5 1683
I am trying to write a word macro that scans the documents and highlights all the numbers that are less then .95
is this possible to do using a word macro?
i guess i really only need the command that selects a range of numbers.
like if number < .95 or something like that. i am not really a vba person and am used to writing only c++ and python scripts.
i dont know if there's an easy method, but with a DO and a couple of IF it can be done. Something like: - Sub prueba()
-
Dim i As Double
-
Dim j As Integer
-
Dim Dou1 As Double
-
Selection.Start = 0
-
Selection.End = 0
-
For i = 1 To ActiveDocument.Characters.Count
-
j = Asc(ActiveDocument.Characters(i))
-
If (j >= 48 And j <= 57) Or j = 46 Then
-
If Selection.End < i - 1 Then
-
Selection.Start = i - 1
-
Selection.End = i
-
Else
-
Selection.End = i
-
End If
-
Else
-
If Selection.End = i - 1 Then
-
Dou1 = Selection.Text
-
If Dou1 < 0.95 Then
-
Selection.Font.Bold = True
-
End If
-
End If
-
End If
-
Next
-
End Sub
HTH
i am getting a type mismatch at the
The file does contain letters and numbers and different characters in it. Could there be a mismatch because i, j, Dou1 are all defined as numbers. Also, i am sure there is a good reason for it, but why is this line in the code and what does it do: -
If (j >= 48 And j <= 57) Or j = 46 Then
-
i am getting a type mismatch at the
The file does contain letters and numbers and different characters in it. Could there be a mismatch because i, j, Dou1 are all defined as numbers. Also, i am sure there is a good reason for it, but why is this line in the code and what does it do: -
If (j >= 48 And j <= 57) Or j = 46 Then
-
actually the error was because there are periods without numbers. because it searches for numbers an dots, and if it finds a dot without a number and try it as a number it will show you the error. so all you have to do is in the line above the error, change the IF for this one If Selection.End = i - 1 And (Selection.End - Selection.Start > 1) Then
That will check if the selected ranges are bigger than one... (this will fix this problem, but if you use suspensive, it will give you an error again because you'll have "..." that is larger than one but still no number).
what im doing is using an integer "j" to store the ascii code of each character
the ascii code for 0 is 48 , the code for 9 is 57 and all the numbers are between them. 46 is for a dot.
HTH
ohhhh ok. well in that case i am still getting an error because i have many ....... in a row in various places.
this is what my document looks like and i want to highlight the number in the middle that are less then .95000 aditionally i want to highlight the number to the right of it and the numbers and text to the left of it as well but that might be too complicated.
42062 ALTA_L98 69.000 0.95212 0.98269
42820 HS_TAP69 69.000 0.93047 0.97650
44400 KARSTN 9 69.000 0.92176 0.97748
42080 ALVIN 9 69.000 0.92959 0.97614
44380 JULIFF 69.000 0.92045 0.98942
44440 MANVEL 9 69.000 0.92236 0.97481
my document also contains all kinds of different characters and symbols like:
-, <, >, $, :, &, etc.
ohhhh ok. well in that case i am still getting an error because i have many ....... in a row in various places.
...
my document also contains all kinds of different characters and symbols like:
-, <, >, $, :, &, etc.
Then i think the easiest way to make it work will be making it ignore this errors, since "....." cant be compared, it will never highlight so just ask vb not to tell you that it isnt a number. Add this line before the FOR starts: on error resume next
Now for the other numbers you wanted to hightlight, give it a try by yourself using selection.start and selection.end
HTH
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Poster |
last post by:
After creating an IN clause from a bunch of character strings created by a
Word macro, Query Analyzer complains about a syntax error. The macro takes a
column full of character strings and wraps...
|
by: bekil |
last post by:
Thanks for your suggestion Murray Jack.
I also record macro while doing it manually in word then I edit the
macro to see the required code.
Firstly I am creating a blank page. Secondly I go to...
|
by: David Ford |
last post by:
I have a macro that I use across the board for freeing ram. I'd like to
clean up my code so I don't get these warnings.
#define sfree(x) _internal_sfree((void **)&x)
#define _internal_sfree(x)...
|
by: Brian Kwan |
last post by:
Requirement: Call a Word Macro from ASP.NET with parameters
Do anyone have idea about this? Please notice the import statement and
sample code, as I am a beginner using ASP.NET, thanks for your...
|
by: Mason |
last post by:
I'm having some problems converting VBA for Word 2000 to code that
VB.Net understands. I recorded a macro in Word to add numbering (a.
b. c.) to my paragraphs. I managed to translate quite a bit...
|
by: WØCBF |
last post by:
I am trying to copy the information from a form into a table. I have
tried running the sql code from a macro by using the command :
This works and writes the work 'test' into the field name...
|
by: Takeadoe |
last post by:
Dear NG,
Can someone assist me with writing the little code that is needed to
run an update table query each time the database is opened? From what
I've been able to glean from this group, the...
|
by: Eric Layman |
last post by:
Hi,
I have fields from textareas.
With a click of a button, php is able to grab these fields and by using
header(), convert the output to Ms Word doc.
But the outcome of the word doc...
|
by: Ed from AZ |
last post by:
I'm using Word 2003. I use a proprietary Java program that takes all
the information in the various forms and generates an XML file.
There
are times I need to move information between files. I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |