vba 禁用警告:您将大量数据复制到剪贴板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/645861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 09:40:21  来源:igfitidea点击:

Disable warning: You copied a large amount of data onto the clipboard

ms-accessvbams-officems-access-2007

提问by Knox

While debugging queries written in MS Access 2007 (problem was the same in all previous versions too), I'll run the query and then copy the results into Excel. Depending on results, I switch batch to Access to refine the results and go back into design mode of the query. At this point, I get an annoying warning: you copied a large amount of data onto the clipboard. ...Do you want to save this data on the clipboard?I have never wanted to do this.

在调试用 MS Access 2007 编写的查询时(问题在所有以前的版本中也相同),我将运行查询,然后将结果复制到 Excel 中。根据结果​​,我将批处理切换到 Access 以优化结果并返回到查询的设计模式。在这一点上,我收到一个恼人的警告: you copied a large amount of data onto the clipboard. ...Do you want to save this data on the clipboard?我从来不想这样做。

The MS Office clipboard is disabled so this function is happening with the standard Windows clipboard. Is there a way to disable the warning and assume No as the default?

MS Office 剪贴板已禁用,因此此功能在标准 Windows 剪贴板中发生。有没有办法禁用警告并假设否作为默认值?

采纳答案by Ron

There is a very easy solution to this. The warning message only happens if there is a LARGE amount of stuff on the clipboard. Therefore - make sure there is only a small amount of stuff there before you close.

对此有一个非常简单的解决方案。只有在剪贴板上有大量内容时才会出现警告消息。因此 - 在关闭之前确保那里只有少量的东西。

For example, in a macro I wrote I do this:

例如,在我写的一个宏中,我这样做:

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
Windows("iostatZd15.1").Activate
ActiveWindow.WindowState = xlNormal
ActiveSheet.Range("A1").Copy
ActiveWindow.Close

The second-last line (immediately before the close) is a "dummy" - a command to simply replace the current (BIG) clipboard with a very small amount of data. It works.

倒数第二行(紧接在收盘前)是一个“虚拟”——一个用非常少量的数据简单地替换当前(大)剪贴板的命令。有用。

回答by Ovi Tisler

I think you may have to disable the MS clipboard. Try this:

我认为您可能必须禁用 MS 剪贴板。尝试这个:

  1. Quit any programs that are running.
  2. Click Start, and then click Run. Type regedit and click OK.
  3. In the Registry Editor, click to select the following subkey (folder): HKey_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General
  4. On the Edit menu, point to New and click DWORD Value. With New Value #1 selected, type AcbControl, and then press ENTER.
  5. On the Edit menu, click Modify. In the Edit DWORD Value dialog box, click Decimal under Base. Type 1 in the Value data box. Click OK and quit the Registry Editor.
  1. 退出任何正在运行的程序。
  2. 单击开始,然后单击运行。键入 regedit,然后单击确定。
  3. 在注册表编辑器中,单击以选择以下子项(文件夹): HKey_CURRENT_USER\Software\Microsoft\Office\9.0\Common\General
  4. 在编辑菜单上,指向新建并单击 DWORD 值。选择新值 #1 后,键入 AcbControl,然后按 Enter。
  5. 在编辑菜单上,单击修改。在“编辑 DWORD 值”对话框中,单击“基数”下的“十进制”。在数值数据框中键入 1。单击“确定”并退出注册表编辑器。

NOTE: You cannot disable (or enable) the Office Clipboard for only a single Office program by modifying the registry.

注意:您不能通过修改注册表仅为单个 Office 程序禁用(或启用)Office 剪贴板。

Here's the MS KB article

这是MS KB 文章

回答by David-W-Fenton

In my experience, you only get this message when you close an application. Are you closing Excel before returning to Access? If so, don't close it and see if you no longer get the message.

根据我的经验,您只有在关闭应用程序时才会收到此消息。您是否在返回 Access 之前关闭 Excel?如果是这样,请不要关闭它并查看您是否不再收到该消息。

EDIT after trying instructions for producing the error:

在尝试产生错误的说明后进行编辑:

The only way to avoid the error message is to turn off notifications before entering design view, as in:

避免错误消息的唯一方法是在进入设计视图之前关闭通知,如下所示:

  DoCmd.SetWarnings False

And you'd want to turn it back on after you are done with your editing.

并且您希望在完成编辑后重新打开它。

But there's no place to run this code, since you're just using the Access UI to edit a query.

但是没有地方可以运行此代码,因为您只是在使用 Access UI 来编辑查询。

I don't quite understand whythis warning is considered a problem. Maybe you're pasting, going back to design view, changing criteria, running again, pasting again? If so, turning SetWarnings off might do the trick.

我不太明白为什么这个警告被认为是一个问题。也许您正在粘贴、返回设计视图、更改标准、再次运行、再次粘贴?如果是这样,关闭 SetWarnings 可能会奏效。

If you wanted it to happen automatically, you could conceivably use the Screen.ActiveDatasheet object to do this. What you'd want to do is write a function:

如果您希望它自动发生,您可以想象使用 Screen.ActiveDatasheet 对象来执行此操作。你想要做的是写一个函数:

  Public Function ChangeWarnings(bolSetting As Boolean) As Boolean
    DoCmd.Setwarnings bolSetting
  End Function

...then when you open your query in datasheet view, in the Immediate window, type these two lines:

...然后当您在数据表视图中打开查询时,在立即窗口中,键入以下两行:

  Screen.ActiveDatasheet.OnActivate = "=ChangeWarnings(False)"
  Screen.ActiveDatasheet.OnDeactivate = "=ChangeWarnings(True)"

You could also certainly write code that sets this up for you.

您当然也可以编写代码来为您进行设置。

One note -- it doesn't "stick" for the Screen.ActiveDatasheet object when opening or closing a different one. It applies only to the Datasheet that is active when you assign the event actions.

一个注意事项——当打开或关闭另一个对象时,它不会“粘住” Screen.ActiveDatasheet 对象。它仅适用于分配事件操作时处于活动状态的数据表。

回答by KevenDenen

You could set the OnClose event of the form up to clear the clipboard.

您可以设置表单的 OnClose 事件以清除剪贴板。

Put the below code into a module in your database.

将以下代码放入数据库中的模块中。

Private Declare Function apiOpenClipboard Lib "User32" Alias
"OpenClipboard" (ByVal hWnd As Long) As Long

Private Declare Function apiEmptyClipboard Lib "User32" Alias
"EmptyClipboard" () As Long

Private Declare Function apiCloseClipboard Lib "User32" Alias
"CloseClipboard" () As Long

Function EmptyClipboard()
  If apiOpenClipboard(0&) <> 0 Then
    Call apiEmptyClipboard
    Call apiCloseClipboard
  End If
End Function

Then in the Close event of your form use:

然后在表单的 Close 事件中使用:

EmptyClipboard

回答by josh

For Excel:

对于 Excel:

Fexcel = New Microsoft.Office.Interop.Excel.Application
Fexcel.DisplayAlerts = False

Do same for Access

对 Access 执行相同操作

回答by user3246838

Application.CutCopyMode = False

Application.CutCopyMode = False

回答by Johnny D

I run into this problem all the time. It seems silly to have to do this, but the following solution kills it dead.

我一直遇到这个问题。必须这样做似乎很愚蠢,但以下解决方案将其杀死。

' Copy something small into the clipboard
Range("A1").Copy

' Turn off CutCopyMode i.e., the "crawling ants"
' Application.CutCopyMode = False solves a lot of problems, I do it as a precaution after I copy anything
Application.CutCopyMode = False

CutCopyMode = FALSE does not turn off the all clipboard copying (as stated by another poster)

CutCopyMode = FALSE 不会关闭所有剪贴板复制(如另一张海报所述)