PDA

View Full Version : Selected Text to Envelope



Anne Troy
04-02-2007, 06:27 AM
Would love, love, LOVE a macro that'll accomplish the following:

1. Copy the selected text
2. File-->New and choose env.dot
3. Edit-->Paste special as unformatted text
4. Print

COOOOOOOL. :D

fumei
04-02-2007, 08:26 AM
Selection.Copy
Documents.Add Template:="path to template"
Selection.PasteAndFormat (wdFormatPlainText)
ActiveDocument.PrintOutdoes not work?

fumei
04-02-2007, 08:30 AM
What about:Selection.Copy
Documents.Add Template:="path to template"
Selection.Range.PasteSpecial DataType:=wdPasteText
ActiveDocument.PrintOut

This gives unformatted text.

What exactly is happening?

lucas
04-02-2007, 10:18 AM
Anne, could you possibly post your template file? A bookmark in the template would probably help wouldn't it Gerry?

fumei
04-03-2007, 03:16 AM
I don't know. I don't know what a bookmark would do for the apparent issue - getting unformatted text from the paste.

As stated, a Selection is copied into a newly created document from a template, with the desire for the paste of that copy to have no carried-over format. At least I think that is the issue.

There is no mention of positioning, or placement, so I am not seeing (for now) that a bookmark would be relevant. If the paragraph (and more relevantly, its style) that contains the bookmark has a undesired format , then placing the paste into the bookmark should not help.

What are you thinking, vis-a-vis a bookmark?

So, Anne...whazzzup?

lucas
04-03-2007, 07:19 AM
positioning is what I was thinking Gerry...
It just seems that if it's a template that we're automating that it should know where to paste the selection...that's all. Assuming here that the return address is static.

fumei
04-03-2007, 08:44 AM
We don't know. From a straightforward interpretation of the post, the paste is a point 0 - the template makes a new file, and there is no movement, there is only the paste. It is at the start of the new document/file.

No movement, no placement was mentioned.

Anne Troy
04-06-2007, 08:24 AM
Of course, I'm a dork. I had to change my email address so I get notifs again. LOL. Guys, THANKS!! I recall that I couldn't record this macro for some reason. So, I tried earlier today, and had no problem at all. The code looks like this:
Sub Macro1()
Documents.Add Template:= _
"C:\Documents and Settings\Jack's office\Application Data\Microsoft\Templates\env.dot" _
, NewTemplate:=False, DocumentType:=0
Selection.PasteAndFormat (wdPasteDefault)
Selection.WholeStory
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(4)
End With
Selection.HomeKey Unit:=wdStory
End Sub

I'm sure it could be sweeter. :)
Thanks for all your help!

Ger: I did look at that book. I do plan to give it a thorough going over. Family stuff is just taking priority right now.

lucas
04-06-2007, 08:43 AM
Hi Anne,
from Gerry's post...this will paste unformatted text:
Selection.Range.PasteSpecial DataType:=wdPasteText