Alexis Posted September 7, 2016 Report Share Posted September 7, 2016 Greetings, when I use "Text Type --> Paste Rich Text" in a Word Document it also changes the Pagelayout. Is there a way to prevent that from happening? Atm I use "Use Cliptboard and Paste Text" instead which works fine but doesn't let me pre-format text. Quote Link to comment Share on other sites More sharing options...
Cory Posted September 7, 2016 Report Share Posted September 7, 2016 I don't know but that sounds like an issue with Word. I know in many Office applications they get clever when you paste things in. Like automatically applying styles and such. Try the same macro in WordPad. Also try pasting in the text manually. Quote Link to comment Share on other sites More sharing options...
Alexis Posted September 8, 2016 Author Report Share Posted September 8, 2016 Thank You, great advice as always!!! It works in Wordpad using a .rtf-file. I never would have thought of this. It must have something to do with the fileformat (doc vs rtf) and what actually is the content of a rich text clipboard. I don´t really understand it but am i happy you showed me the way. Quote Link to comment Share on other sites More sharing options...
Cory Posted September 9, 2016 Report Share Posted September 9, 2016 People often think when you paste in an Office app that is all that happens. That is not the case at all. When you paste into any of them they take what's on the clipboard and analyze it and often change it or even things in the document. Like maybe it sees some RichText with bullet characters. Well it might take this and decide "Ah ha! He wants a numbered list!" And then convert your text to a series of items i a numbered list. Now it might look similar but under the hood they're nothing alike. Not only will it change the string data you sent it but it will also change the styles in Word. Remember Word is a style based word processor. If you ever manually bold a header, change a font or it's size, or add carriage returns to make spaces your not using it correctly. It's all about styles. IE if you want more space after some text change that in the definition of the style your'e using. Everything is in a style in Word. The reason I mention this is Word knows that's the proper way and i'm guessing when pasting formatted text in Word it will probably get clever and change a style. The best example I have is in Excel since I don't often automate Word. You might not realize this but Excel cells are set to a type of data. They are DateTime, Money, Boolean, Numeric, and String. If I have a GL (General Ledger) code of "12RG" Excel takes that and decided it's not a number or any other type of data and brings it in as string. Cool. That's what I intended and need. Now my lookup table works. Then I have a code "2481". Ohhhh now it gets clever and decides that's a number. Then I paste in "MAR2" and although it doesn't look like it to my eye Excel thinks that's a date and changed the cell data type to date and guesses that you mean 2/3/2016 and applies the closest looking date format. Now my cell is a date and it is formatted to look like "2-Mar". IN all these cases my lookup table no longer works. I call it being "clever clever" (said with a haughty English accent). I don't know any way to get around this with MEP. I ended up using a class library in .NET called Interop. It's wonderful. Essentially it's an API that allows a program to do anything a user can. But you need to know how to program in one of the .NET languages to utilize it. If you are ever interested in doing something like this please feel free to contact me outside the forum by giving me your email address in a PM. I'm happy to share my experience for free and maybe even make some small samples for you. Quote Link to comment Share on other sites More sharing options...
Alexis Posted September 9, 2016 Author Report Share Posted September 9, 2016 That´s what i thought. The clipboard as a global utiltiy but all those applications are quite interpreting what to do with the content of the clipboard. Sometimes quite unpredictable. Thank you for offering further understanding and help. Quote Link to comment Share on other sites More sharing options...
rberq Posted September 9, 2016 Report Share Posted September 9, 2016 Thanks, Cory. So THAT'S why I have such trouble with Word. Often I paste data into Notepad, then copy to clipboard and paste into Word to get rid of some of the "clever clever" stuff. I guess I should read up on Styles... Quote Link to comment Share on other sites More sharing options...
Alexis Posted September 10, 2016 Author Report Share Posted September 10, 2016 @ rberq. You may check what format is "Standard" in your word version. This definition ist stored in the document or in new documents in the Normal.dot(m) in Templates. It´s likely that Word uses this format. Also consider that you can define in word which format (source or target) it should use if pasting from other or same (Word) Applications in the preferences of word. By pressing CTRL after pasting you can change that default behaviour manually. Quote Link to comment Share on other sites More sharing options...
Cory Posted September 10, 2016 Report Share Posted September 10, 2016 Rberg: What I do sometimes is is set an MEP variable to the clipboard contents then copy it back. It essentially 'cleans' the string. Quote Link to comment Share on other sites More sharing options...
Alexis Posted September 12, 2016 Author Report Share Posted September 12, 2016 Actually i would love to have also the opportunity that a MEP variable saves the whole clipboard (without cleaning) Quote Link to comment Share on other sites More sharing options...
Cory Posted September 12, 2016 Report Share Posted September 12, 2016 MEP doesn't have a clipboard variable. But you there are applications that will. I used to use one called ClipMate and you could save several there and I think there was a hotkey sequence to directly access any one of them. One could use that with MEP to get the same effect. Quote Link to comment Share on other sites More sharing options...
Alexis Posted September 13, 2016 Author Report Share Posted September 13, 2016 Well, i guess it´s worth suggesting that MEP gets clipboard variables, no? Quote Link to comment Share on other sites More sharing options...
Cory Posted September 13, 2016 Report Share Posted September 13, 2016 It would be worth suggesting. However clipboard contents are much more complex than than most realize. EG in Office apps it's something like a DDE link. What it does is to command Excel to send what is selected. IE not the actual value selected. That's how you can 'loose' things you thought you had copied to your clipboard. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.