tags:

views:

19

answers:

1

Hello all,

I'm working on a project to store what a user cuts/copies/pastes within a Word document, and am using the VBA macros to accomplish this. Here's a snippet from the paste macro:

Open "C:\Temp\HoldPastes.txt" For Output As #1
      Write #1, "TestTestTest."
      Write #1, Selection
      Close #1

I'd like HoldPastes.txt to have a list of every chunk of text the user has pasted.

First off, Write #1, Selection is wrong; it puts two quotation marks into my txt file. How can I access what's been pasted from the clipboard and write that to my file?

Also, this overwrites whatever I had in HoldPastes.txt. I'd like to preserve all pastes in this file, so how can I tell the macro to pick up where it left off and add to the file?

+2  A: 

Append to a file is not For Output but For Append

Open "C:\Temp\HoldPastes.txt" For Append As #1

Read the Clipboard

Dim myData As DataObject
Dim strClip As String

Set myData = New DataObject
myData.GetFromClipboard
strClip = myData.GetText

Hope this helps

Scoregraphic