Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-15-2017, 06:29 AM
gmaxey gmaxey is offline Error with Clipboard - Getting Spaces Out of Clipboard Windows 7 32bit Error with Clipboard - Getting Spaces Out of Clipboard Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I'm not sure what one of your documents looks like when you initiate this code but why don't you take the spaces out before you ever put it in the clipboard?

Code:
Sub Macro18()
Dim oClipboard As DataObject
Dim oRng As Range
  'This part gets a person's name from a Word document to the oClipboard.
  Selection.EndKey Unit:=wdStory
  Selection.MoveUp Unit:=wdLine, Count:=4
  Selection.EndKey Unit:=wdLine, Extend:=wdExtend
  Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
  Set oRng = Selection.Range
  oRng.Text = Trim(oRng.Text)
  oRng.Copy
  Undo 1 'Put the spaces back in the text.
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Clipboard error Win10 Pro 64 bkcell Windows 1 03-24-2018 04:20 AM
clipboard error freezes workbook bkcell Excel 4 06-18-2017 08:00 PM
Do you want to keep your clipboard? Cam-Bean Word 0 06-14-2017 02:55 AM
Getting the clipboard value: Dataobject error arjfca Word VBA 0 12-04-2014 01:51 AM
Error with Clipboard - Getting Spaces Out of Clipboard Get clipboard Image janith Word 2 05-27-2012 07:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft