Jump to content

How to delete a space in a copy of text please?


Recommended Posts

 

Hello, I copy text to then insert it into software but the problem is that I often have a space before (not always) which suddenly makes me crash my macro. How please to "format" the copied text and remove the spaces. Thanks in advance, have a nice day.

Link to comment
Share on other sites

After you copy the text to the clipboard, you will need to do three things:


1. Transfer the contents of the clipboard into a variable.

2. Do as Cory suggests: "trim" the variable. Trim means to delete spaces from the start and end.

3. Transfer the contents of the variable back to the clipboard.


For example, if this is in your clipboard at the start:

"   Hello World   "

 

The clipboard will be there after you've completed the three steps:

 

"Hello World"

 

The Macro Express code looks something like this:

 

// 1. Transfer clipboard to string variable %Clip%
Variable Set String %Clip% from the clipboard contents
 
// 2. Trim %Clip%
Variable Modify String %Clip%: Trim
 
// 3. Transfer %Clip% to the clipboard
Clipboard Start Copy
  Text Type (Simulate Keystrokes): %Clip%
Clipboard End Copy

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...