I am stuck.
At my organization, we need to check if line numbers are active for a given paragraph. We are attempting to do this but are running into an issue with suppressed line numbers.
We have tried:
Selection.Information(wdFirstCharacterLineNumber)
and
Paragraph.Range.PageSetup.LineNumbers.Active = True
However, the paragraph(s) we are trying to avoid have suppressed line numbers. We are trying to determine whether or not the current paragraph has line numbers.
If line numbers are suppressed LineNumbers.Active returns True for the current paragraph. In addition, if line numbers are suppressed then wdFirstCharacterLineNumber returns 1 for the first paragraph even though it is obviously not 1 as I see 1 in a lower paragraph.
I have not found a function that returns a bool or an integer if line numbers are suppressed for a given paragraph.
I welcome any suggestions. Thank you.
Line numbers are valid for the entire document, which is why what you've tried is returning the information it is.
Line number suppression is direct formatting applied to individual paragraphs, so you need to query the paragraph properties. For example:
If Selection.Paragraphs(1).NoLineNumber Then
'True (-1) means the line numbers are suppressed
Else
'Flase (0) means the line numbers are visible
End If
Related
Write a program for word-wrap which should work on any screen size?
Given a sequence of words, and a limit on the number of characters that can be put in one line (line width). Put line breaks in the given sequence such that the lines are printed neatly. Assume that the length of each word is smaller than the line width.
The word processors like MS Word do task of placing line breaks. The idea is to have balanced lines. In other words, not have few lines with lots of extra spaces and some lines with small amount of extra spaces.
I made a .txt file (UTF-8) and put the following text in it:
123
456
789
I then tried to find out the position of the character '4' by using the InStr() function. Surprisingly, the result was 6. I tried with the character '3', and the result was 3. So, there must be two characters in between the 3 and the 4.
I then tried InStr(TextBox1.Text, Chr(13)) and the result was 4.
Ok. The "New Line" has a character located in the 4th position. If so, then what is 5th character in there?
The actual character(s) used for new-line are different from one platform to the next. Some systems use character 13 to mean a new-line, some use 10, and some, like Windows, use both.
Technically, character 13 is supposed to mean a carriage return (return the print head of the printer to the left side of the page), that's why it's often referred to as CR. Remember, in the early days of computing, printers were used as terminals rather than video screens. So, the closest equivalent of CR on a video terminal is for the cursor to return to the beginning of the current line, but not advance to the next line.
Character 10 means line-feed (LF), which means to advance (i.e. feed) the paper by one line so that the print head is ready to print on the next line. The closest equivalent to a line-feed on a video terminal is to move the cursor down to the next line, but keep it at the same x-position.
So, with those two-things in mind, if you wanted to begin typing at the beginning of the next line, you would need to do both things. You need to advance to the next line on the page AND return to the beginning of the line, hence CRLF, two characters.
Presumably, some system designers thought it was too wasteful to use two characters for each new-line, when the added nuance was rarely needed for computers with video displays, so they opted to only use either CR or LF. Since the correct encoding to use changes from one platform to another, it's best to use Environment.NewLine in .NET to get whichever is appropriate for the current system.
Consider, for example, when you run this console app on windows:
Public Sub Main()
Console.Write("123" & vbCr)
Console.Write("4" & vbCr)
End Sub
The output is:
423
The carriage-return only caused the cursor to go back to the beginning of the line. It didn't cause it to move down to the next line, so the 4, when it's printed, overwrites the 1.
I am trying to create a macro that will search for a single character and perform a specific action based on whether or not the character is at the end (do nothing) or beginning (do something) of a line.
In my quest to find how to do this, I've seen plenty of documentation for determining if the text is at the beginning or end of a document or page or paragraph or on a specific line, or its position in a cell, but nothing about the columnar (I assume)position relative to a line of text.
Does anyone know if such an animal exists?
Thanks in advance!
Selection.Information(wdFirstCharacterColumnNumber) will give you the position of first character in the selected text relative to the line. Is this what you are searching for?
Hi could someone please give me an example of how to read through a text file to the end and read every 5th line as a string? I know how to read a specific line in the text file using
line = System.IO.file.readAllLines(filepath)(linenum)
and also using streamreader to read each line etc..
But I want to go through the whole text file and pick out every certain number of lines. Pretty sure it's got something to do with a loop but I'm not too clued up yet.
As files are not line based, you would need to read all the lines and pick out the ones that you want.
You can use the Where method with the overload that gives you the index of the item, and the Mod operator to determine where every fifth line is:
Dim lines As String() = _
System.IO.File.ReadLines(filepath).Where(Function(line, i) i Mod 5 = 0).ToArray()
The number that you compare the expression to determines which lines you get. i Mod 5 = 0 starts at the first line and then every fifth from there, while i Mod 5 = 4 starts at the fifth line and then every fifth from there.
(The ReadLines method is better than the ReadAllLines for this, as it doesn't read all the lines into memory first, but returns an enumerator so that you can process the lines as they are read.)
I am asking for some homework help. I am not asking for the answer,I just wanted to be pointed in the right direction.
I have a program in C which I am new to. I have to recreate a Unix tool using vi. Its job will be to read input and “neaten” it up. It reads in paragraphs of words and rearranges them such that they fit nicely onto a line of specified width, inserting line breaks as needed. A paragraph is separated from other paragraphs by one or more empty lines than changing the width with -w and changing to right alignment using -r.
Next would be to justify the text using -j so that every line with more than one word extends from the left to the right with max width. I need to apply integer division to calculate the total number of spaces that should have been seen by the time you finish a gap using Kevin Woods Si = i*S/G where S is the total number of spaces needed in the line, G is the number of gaps between words in the line and Si is the number of spaces that should have appeared by the end of the i'th gap. Lastly suppress line spacing from lines entered with more than a double line back into a double line.
The options should be cumulative—I can specify width, alignment, and skipping of blank lines together. The -r and -j flags should not be used together.
first step: metacode
main(arguments)
analyse arguments f.e. with getopt() for correctness and validity
read the original text
break the text into virtual paragraphs (identified by a double LineBreak)
for each paragraph
break it into lines of less than allowed (-w, default 80) characters
for each line that is not the last line of a paragraph
fill with spaces according to your algorithm and command line spezification
print out all lines
second step: coding
this is your task. Please come back, when you have code, that shows us, where you are stuck.