Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Paste Plain Text
#1
I need to copy from an Excel cell - or any other source, strip out all rich text attributes, and paste:


I have Excel 2007 and an old finicky Access 2000 program that runs on the old Access 2000 runtime.

I have a macro that pastes the clipboard contents into the Access program for a search function. But seems to only read plain text. If I paste from Excel it pastes, and looks right, but finds nothing.

Type in the exact same string manually, and there is no problem.

So:

Is there a way to make the contents of the current clipboard into plain text?

I think this will solve my issue (I sure hope so)
#2
str s
s.getclip ;;gets clipboard text, only plain
...
s.setclip ;;sets clipboard text
#3
Thanks Gintara,

Didn't work. Strange thing.

What works manually:
Go into edit of an excel cell, copy the plain text directly, paste, and search works.
Copy the entire cell, paste into text editor (or notepad), copy from text editor, paste and search works.

Mimicking this in a macro performs exactly the same only when paste occurs nothing is found

I used
Code:
Copy      Help
key "FRS57"
(FRS57 being the search term) and that worked - but I can't hard code this, I need to pull from clipboard.

This is my simple code:
Code:
Copy      Help
;int w1=act(win("UltraEdit-32 - [Edit4*]" "Afx:00400000:8:00010013:00000000:*""" 0x800))
;'Cv
;'SH Cx


if win("Valogix Planner" "OMain")
,act win("Valogix Planner" "OMain")
,'Cf
,str s
,s.getclip ;;gets clipboard text, only plain
,s.setclip ;;sets clipboard text
,;key "FRS57"
,
,'Cv

I can't understand why it treats clipboard contents delivered by QM differently than manually.
#4
When you copy a cell in Excel, sometimes it is followed by new line. Try to insert

s.rtrim("[]")

after s.getclip.

Also you can replace s.setclip 'Cv to s.setsel (without 'Cv).
#5
Gintaras, I wish I could shake your hand.

Thank you! That was all there was to it.

You have made my day with this - this lets me automate this clunky old access app and makes my days a lot easier.

Cheers Gintaras

Big Grin Tongue


Forum Jump:


Users browsing this thread: 1 Guest(s)