Re: need code to copy paste extended

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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

.



Relevant Pages

  • Re: problem reading word file...
    ... ReadWordDocument = wdDoc.Bookmarks.Range.Text ... Besides being wasteful of processing resources, the use of the clipboard ... Function ReadWordDocument(ByVal sPathName As String) As String ... Dim wdToepassing As New Word.Application ...
    (microsoft.public.word.vba.general)
  • Re: Copy the File name of active document into the clipboard
    ... clipboard via VBA? ... a new document and copy the string from there. ... Dim strName As String ...
    (microsoft.public.word.vba.general)
  • Re: need code to copy paste extended
    ... The subroutine below assumes that the selected text plus the name of the ... Dim strTrans As String ... Dim objDoc As Word.Document ... Dim strPlus As String ...
    (microsoft.public.word.vba.general)
  • RE: automate reports -- copy to clipboard
    ... clipboard, so I guess I'll keep searching. ... You might write the string on Visio drawin and select text in edit mode. ... Dim doc As Visio.Document ... Dim FileName As String ...
    (microsoft.public.visio.developer.vba)
  • Re: Changing font colors of concatenated strings
    ... then copy it to the clipboard. ... Dim str1 As String ... Dim str3 As String ...
    (microsoft.public.dotnet.languages.vb)