?
Solved

Word VBA Delete last word from string

Posted on 2012-03-12
2
Medium Priority
?
3,011 Views
Last Modified: 2012-03-14
Hi experts

I need to delete the last word from my string.

I have the code below that tells me the last word in the string, but I can't work out how to manipulate it so that I end up with my string equalling "The quick brown" rather than "The quick brown fox.

Dim Str As String
Str = "The quick brown fox"
MsgBox Right(Str, Len(Str) - (InStrRev(Str, " ") - 1))

Open in new window

0
Comment
Question by:Fi69
2 Comments
 
LVL 11

Accepted Solution

by:
rowansmith earned 600 total points
ID: 37712964
MsgBox Left(Str,InStrRev(Str, " ") - 1)
0
 

Author Closing Comment

by:Fi69
ID: 37722886
Thank you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question