D
daniel lie
Hi,
I was wondering if anyone might be able to help me with the following
problem that i'm having.
Is there a way of figuring out where the cursor is in a document?
The reason for that is I have a code that would insert a new Section in the
document report.
Here is the code
' Insert a heading for the new section.
Selection.Style = ActiveDocument.Styles("Section Heading 1")
' Insert the heading's text based on InputBox entry.
' Add a paragraph break to return to "Normal" text.
Selection.InsertBreak Type:=wdPageBreak
Selection.TypeText Text:=InputBox("Please enter section heading:", "Enter
Section Heading")
Selection.TypeParagraph
This will work if the cursor is on the newline. It would place another
section (e.g. Section 2) on the next page. However, the problem arises when
the cursor is not on the newline.
For example,
Section 1. Water Sewage
Blah blah
Classification report
If the user by accident leaves the cursor at the end of the word "report"
and select the macro to insert a new section, it'd be stuffed up.
Instead of getting Section 2 to show on the next page, i'd get as follows:
Section 1. Water Sewage
Blah blah
Section 2. Classification report
--------- page break -------
Section 3. Reconciliation
Not sure if anyone would like to throw in some ideas here. What i come up
with is if we could find out where the cursor is and can check to see if
it's at the newline or not.
Your help'd be greatly appreciated.
Thank you in advance
url:http://www.ureader.com/gp/1022-1.aspx
I was wondering if anyone might be able to help me with the following
problem that i'm having.
Is there a way of figuring out where the cursor is in a document?
The reason for that is I have a code that would insert a new Section in the
document report.
Here is the code
' Insert a heading for the new section.
Selection.Style = ActiveDocument.Styles("Section Heading 1")
' Insert the heading's text based on InputBox entry.
' Add a paragraph break to return to "Normal" text.
Selection.InsertBreak Type:=wdPageBreak
Selection.TypeText Text:=InputBox("Please enter section heading:", "Enter
Section Heading")
Selection.TypeParagraph
This will work if the cursor is on the newline. It would place another
section (e.g. Section 2) on the next page. However, the problem arises when
the cursor is not on the newline.
For example,
Section 1. Water Sewage
Blah blah
Classification report
If the user by accident leaves the cursor at the end of the word "report"
and select the macro to insert a new section, it'd be stuffed up.
Instead of getting Section 2 to show on the next page, i'd get as follows:
Section 1. Water Sewage
Blah blah
Section 2. Classification report
--------- page break -------
Section 3. Reconciliation
Not sure if anyone would like to throw in some ideas here. What i come up
with is if we could find out where the cursor is and can check to see if
it's at the newline or not.
Your help'd be greatly appreciated.
Thank you in advance
url:http://www.ureader.com/gp/1022-1.aspx