Excel and Notepad: how avoid additional inverted commas after copy and paste?

M

marco2

Hi,
If I write a multi-line text in a cell (then go down with alt+enter)
and after copy the cell pasting on Notepad, it display before inverted
commas and after textual content.
Instead, if I select directly the content from the formula bar, it
isn't happen.
Do exist a way for copy and paste directly from the cell without
select from the formula bar?
Maybe with a macro?

Thank
Marco

__________________
http://www.idee-regalo.biz/catalogo-stereogrammi-3.html http://www.ghisirds.it/
http://scuo.la/ http://www.righettofabrizio.com/pantografo-taglio-plasma.html
 
D

Dave Peterson

I used the PutOnClipboard routine that Chip Pearson has:
http://www.cpearson.com/excel/clipboard.htm

With this sub:
Option Explicit
Sub testme()
PutOnClipboard ActiveCell.Text
End Sub

And then pasted (manually) into NotePad. No double quotes were inserted.

Chip has instructions that you have to follow (including the tools|references
with "Microsoft Forms 2.0 object library") on that sheet.
 
M

marco2

I used the PutOnClipboard routine that Chip Pearson has:http://www.cpearson.com/excel/clipboard.htm

With this sub:
Option Explicit
Sub testme()
PutOnClipboard ActiveCell.Text
End Sub

And then pasted (manually) into NotePad. No double quotes were inserted.

Chip has instructions that you have to follow (including the tools|references
with "Microsoft Forms 2.0 object library") on that sheet.

In the meantime, thank you for the reply but Notepad was an example.
Really I must paste the cell content on other programs that operate as
Notepad.
Then the contents without inverted commas have to stay only on
clipboard.
Is it possible?
Thank you very much!
Marco
 
D

Dave Peterson

I don't know. I think it'll depend on how the other program(s) behave.

What happened when you tried it using Chip's code and your program(s).
 
M

marco2

I don't know. I think it'll depend on how the other program(s) behave.

What happened when you tried it using Chip's code and your program(s).

thanks to all!
I solved the problem and it is work.


Sub TestMacro()
Dim objClip As DataObject
' Microsoft Forms 2.0 Object Library
' needs to be selected as a Reference (on the VBA Tools menu)
Dim strTmp As String
Set objClip = New DataObject
strTmp = Replace(ActiveCell.Value, Chr(10), vbCrLf)
objClip.SetText strTmp
objClip.PutInClipboard
Set objClip = Nothing
End Sub


best regards.
 
G

Guest

this sounds like exactly what i need to do but i am not familiar with VBA.
can you let me know how i can do this in excel for the cells i need to past
without the quotation marks?
 
G

Guest

if i have a formula like =W21&CHAR(13)&(CHAR(10))&Y21
where W21 and Y21 are text...do you know how i can copy the results of this
cell and paste it into notepad without getting the quotes inserted?
 
D

Dave Peterson

Did you try the macro?

Since you have the CR and LF in the cell, you could modify it like:

Option Explicit
Sub TestMacro()
Dim objClip As DataObject
' Microsoft Forms 2.0 Object Library
' needs to be selected as a Reference (on the VBA Tools menu)
Dim strTmp As String
Set objClip = New DataObject
strTmp = ActiveCell.Value
objClip.SetText strTmp
objClip.PutInClipboard
Set objClip = Nothing
End Sub

Assumes that the activecell is the cell with that formula.
 
G

Guest

I ran this macro on the cell but i still am unable to copy and paste without
the quotes.
 
D

Dave Peterson

The macro does the copy.

Run the macro (which does the copy)
then paste into Notepad
I ran this macro on the cell but i still am unable to copy and paste without
the quotes.
 
G

Guest

oh yes that does work..thank you.. but how do i get it to run that macro in
that column when i open the worksheet?
 
G

Guest

actually i would like it to do multiple cells in a column each having that
formula and be able to paste it into notepad. is that possible?
 
D

Dave Peterson

Maybe you can start with this code and change it to what you need.

It grabs all the cells in C1:C### (where ### is the last row used in column C).

Option Explicit
Sub TestMacro()
'Microsoft Forms 2.0 Object Library
'needs to be selected as a Reference (on the VBA Tools menu)

Dim objClip As DataObject
Dim myCell As Range
Dim myRng As Range
Dim myStr As String

With Worksheets("sheet1")
Set myRng = .Range("C1", .Cells(.Rows.Count, "C").End(xlUp))
End With

myStr = ""
For Each myCell In myRng.Cells
myStr = myStr & vbCrLf & myCell.Value
Next myCell

myStr = Mid(myStr, Len(vbCrLf) + 1)

Set objClip = New DataObject
objClip.SetText myStr
objClip.PutInClipboard
Set objClip = Nothing

End Sub

You could run it by hitting alt-f8 and running the code from that dialog.
DV said:
actually i would like it to do multiple cells in a column each having that
formula and be able to paste it into notepad. is that possible?
 
G

Gord Dibben

"Stuck" means what?

Error message and macro stops?

Do you have a "sheet1" in your workbook?

Worksheet names are case-sensitive.


Gord Dibben MS Excel MVP

I am getting stuck on the following:
With Worksheets("sheet1")

any ideas?
 
D

Dave Peterson

When used like this:
With worksheets("Sheet1")
the name isn't case sensitive.

But I bet Gord hit the nail on the head when he asked if you have a sheet named
Sheet1 in your workbook.
 
G

Guest

Run-time error '9': Subscript out of range.

Gord Dibben said:
"Stuck" means what?

Error message and macro stops?

Do you have a "sheet1" in your workbook?

Worksheet names are case-sensitive.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top