Re: need code to copy paste extended
- From: Co <vonclausowitz@xxxxxxxxx>
- Date: Fri, 19 Oct 2007 16:04:26 -0000
On 19 okt, 16:40, "Steve Yandl" <syandl_nos...@xxxxxxxxxxx> wrote:
The subroutine below assumes that the selected text plus the name of the
document (and a space between the two strings) will be appended to a Word
document named "C:\Test\myLog.doc" and that myLog.doc is not already open.
The clipboard isn't being utilized so there is no need for the forms object
library to be available.
_____________________________________
Sub LotTxtSelection()
Dim strTrans As String
Dim objDoc As Word.Document
strTrans = Selection.Text & " " & ActiveDocument.Name
Set objDoc = Documents.Open("C:\Test\myLog.doc")
objDoc.Activate
With Selection
.WholeStory
.MoveRight
.TypeParagraph
.TypeText strTrans
End With
objDoc.Save
objDoc.Close
End Sub
_____________________________________
Steve
"Co" <vonclausow...@xxxxxxxxx> wrote in message
news:1192773821.071054.47680@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 19 okt, 00:32, "Steve Yandl" <syandl_nos...@xxxxxxxxxxx> wrote:
It copies the text that was selected in your document appended with the
name
of the active document. You didn't specify a target where you wanted it
pasted so I assumed you would be pressing Ctrl plus v or using some other
method to paste the contents into some other Word document or other
application.
If your intent was to send the text to a different word document or some
text log file, there are better ways to go about it than involving the
Windows clipboard. What is the ultimate goal?
Steve
"Co" <vonclausow...@xxxxxxxxx> wrote in message
news:1192744307.789810.290470@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 18 okt, 23:07, "Steve Yandl" <syandl_nos...@xxxxxxxxxxx> wrote:
Marco,
You need a reference to the Microsoft Forms object library. Just
insert
a
UserForm that won't get used and then go back to a module to create
the
subroutine. The sub between the lines should then do what I think
you're
asking to do.
______________________________
Sub CopyPlusDocName()
Dim myDataObject As DataObject
Dim strPlus As String
strPlus = Selection.Text & ActiveDocument.Name
Set myDataObject = New DataObject
myDataObject.SetText strPlus
myDataObject.PutInClipboard
End Sub
______________________________
Steve
"Co" <vonclausow...@xxxxxxxxx> wrote in message
news:1192714699.607589.290760@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi All,
I need some VBA code that will Copy a highlighted part of a document
to the clipboard including
the name of my document (ActiveDocument.Name).
So when I paste it in a new blanc document I will have the
highlighted
text and at the end of it my filename, like:
"This is my highlighted text which was copied from another
document".
MySourceDoc.20071018.doc
Marco
Steve,
I don't quite understand.
I inserted a UserForm1 and then ran your code but it doesn't Paste
anywhere.
Marco
The goal is to manually select a part of text in my word document.
Then copy that text together with the name of the document into
another (new)
word document, like:
"This is the text that I am going to copy into a new
Document including the name of the source document"
THE.NAME.OF.MY.SOURCE.DOC.20071019.doc
Marco
Looks great Steve,
But could this also be done with a new document which is already
opened
and of which we do not know the name?
Marco
.
- Follow-Ups:
- Re: need code to copy paste extended
- From: Russ
- Re: need code to copy paste extended
- From: Jean-Guy Marcil
- Re: need code to copy paste extended
- References:
- need code to copy paste extended
- From: Co
- Re: need code to copy paste extended
- From: Steve Yandl
- Re: need code to copy paste extended
- From: Co
- Re: need code to copy paste extended
- From: Steve Yandl
- Re: need code to copy paste extended
- From: Co
- Re: need code to copy paste extended
- From: Steve Yandl
- need code to copy paste extended
- Prev by Date: Re: How can I call a macro from an unviewable project
- Next by Date: Re: need code to copy paste extended
- Previous by thread: Re: need code to copy paste extended
- Next by thread: Re: need code to copy paste extended
- Index(es):
Relevant Pages
|