2 Simple Newbie-Type Questions, I hope

L

L.A. Lawyer

1. I want to strip out only the last character of a long string, called
StrList. The left function doesn't seem to deal with characters.

2. I want Word to:
a. Go to the very bottom of a document.
b. Put in a hard page.
c. Drop in another text file as the new last page of the active
document.

How are these done
 
J

Jean-Guy Marcil

L.A. Lawyer was telling us:
L.A. Lawyer nous racontait que :
1. I want to strip out only the last character of a long string,
called StrList. The left function doesn't seem to deal with
characters.

Yes it does. It is in fact used strictly for characters in a string...
Select a long paragraph in a document and try this:

'_______________________________________
Dim StrList As String

StrList = Selection.Text
MsgBox "StrList contains " & Len(StrList) & " Characters."

StrList = Left(StrList, Len(StrList) - 1)
MsgBox "StrList now contains " & Len(StrList) & " Characters."
'_______________________________________
2. I want Word to:
a. Go to the very bottom of a document.
b. Put in a hard page.
c. Drop in another text file as the new last page of the
active document.

'_______________________________________
Dim myDocRge As Range

Set myDocRge = ActiveDocument.Range

With myDocRge
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakNextPage
'Section breaks are more reliable in a case like this
'if you really want a page break:
'.InsertBreak wdPageBreak
.InsertFile "C:\Test.doc"
'If you want a linked file:
'.InsertFile "X:\Test.doc", , , True
'or:
'.InsertFile FileName:="X:\Test.doc", Link:=True
End With
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top