从单元格复制时留出引号 [英] Leave out quotes when copying from cell
问题描述
问题:
从程序外的Excel复制单元格时,将自动添加双引号。
Problem:
When copying a cell from Excel outside of the program, double-quotes are added automatically.
详细信息:
我在Windows 7机器上使用Excel 2007。如果我有一个具有以下公式的单元格:
Details:
I'm using Excel 2007 on a Windows 7 machine. If I have a cell with the following formula:
="1"&CHAR(9)&"SOME NOTES FOR LINE 1."&CHAR(9)&"2"&CHAR(9)&"SOME NOTES FOR LINE 2."
单元格中的输出(格式化为数字)在Excel中如下所示:
The output in the cell (formatted as number) looks like this in Excel:
1SOME NOTES FOR LINE 1.2SOME NOTES FOR LINE 2.
好,好。但是,如果我将单元格复制到另一个程序中,比如记事本,那么在开头和结尾都会引起烦人的双引号。注意CHAR(9)创建的选项卡被保留,这是很好的。
Well and good. But, if I copy the cell into another program, such as notepad, I get annoying double-quotes at the beginning and end. Notice the tabs created by "CHAR(9)" are kept, which is good.
"1 SOME NOTES FOR LINE 1. 2 SOME NOTES FOR LINE 2."
如果我保留这些双引号,复制到另一个程序?换句话说,当单元格复制到剪贴板时,我可以保持这些不被自动添加吗?
How can I keep these double-quotes from showing up, when I copy to another program? In other words, can I keep these from being automatically added when the cell is copied to clipboard?
推荐答案
如果您尝试粘贴WordPlay,Notepad ++或Word你不会有这个问题。
要将单元格值复制为纯文本,要实现您所描述的必须使用宏:
If you try pasting into Word-Pad, Notepad++ or Word you wouldn't have this issue. To copy the cell value as pure text, to achieve what you describe you have to use a macro:
在要将其应用于的工作簿中(或者在您的Personal.xls中,如果要跨多个工作簿使用),请将以下代码放在标准模块中:
In the workbook where you want this to apply (or in your Personal.xls if you want to use across several workbooks), place the following code in a standard module:
代码:
Sub CopyCellContents()
'create a reference in the VBE to Microsft Forms 2.0 Lib
' do this by (in VBA editor) clicking tools - > references and then ticking "Microsoft Forms 2.0 Library"
Dim objData As New DataObject
Dim strTemp As String
strTemp = ActiveCell.Value
objData.SetText (strTemp)
objData.PutInClipboard
End Sub
要将一个标准模块添加到您的项目(工作簿)中,使用 Alt + F11 打开VBE,然后在左上角的项目窗口中右键单击工作簿,然后选择插入>模块。将代码粘贴到代码模块窗口中,该窗口将在右侧打开。
To add a standard module to your project (workbook), open up the VBE with Alt+F11 and then right-click on your workbook in the top left Project Window and select Insert>Module. Paste the code into the code module window which will open on the right.
返回Excel,转到工具>宏>宏,然后选择名为CopyCellContents的宏从对话框中选择选项。在这里,您可以将宏分配给快捷键(例如正常复制的 CTRL + C ) - 我使用 CTRL + Q
Back in Excel, go Tools>Macro>Macros and select the macro called "CopyCellContents" and then choose Options from the dialog. Here you can assign the macro to a shortcut key (eg like CTRL+C for normal copy) - I used CTRL+Q.
然后,当您想将单个单元格复制到记事本/其中,只需执行Ctrl + q(或任何您选择的),然后执行您选择的目的地 CTRL + V 或编辑>粘贴。
Then, when you want to copy a single cell over to Notepad/wherever, just do Ctrl+q (or whatever you chose) and then do a CTRL+V or Edit>Paste in your chosen destination.
我的答案是从以下复制(附加几个): here
My answer is copied (with a few additions) from: here
编辑: (来自评论)
如果在参考列表中找不到Microsoft Forms 2.0库,
您可以尝试
If you don't find Microsoft Forms 2.0 Library in the references list, You can try
- 寻找FM20.DLL(感谢@Peter Smallwood)
- 点击浏览并选择
C:\ Windows \System32\FM20.dll
(32位
Windows)(感谢@JWhy) - 点击浏览并选择
C:\Windows\SysWOW64\FM20.dll
(64位)
- looking for FM20.DLL instead (thanks @Peter Smallwood)
- clicking Browse and selecting
C:\Windows\System32\FM20.dll
(32 bit Windows) (thanks @JWhy) - clicking Browse and selecting
C:\Windows\SysWOW64\FM20.dll
(on 64-bit)
这篇关于从单元格复制时留出引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!