Solved

Word VBA Delete last word from string

Posted on 2012-03-12
2
2,584 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

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

Author Closing Comment

by:Fi69
ID: 37722886
Thank you!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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 how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.

738 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