在不同的计算机上使用文档时无法获取粘贴命令 [英] Cannot get paste command to work when using document on different computers

查看:70
本文介绍了在不同的计算机上使用文档时无法获取粘贴命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用VBA代码组织数据的Excel文档。我正在使用的表单有一个填充信息的布局图片。我正在努力让它打印,但我能够做到这一点的唯一方法是通过打印屏幕和粘贴命令。好吧
当我第一次运行代码时工作正常但是当我在另一台计算机上使用该文档时它不起作用。错误读取粘贴命令失败。


 


这里是代码


    'printlogic =假                       &NBSP ;                 
'将打印逻辑设置为内部命令

    "PrintFrm(假)                      &NBSP ;                    
'打印表格


    Dim wshTemp As Worksheet

    DoEvents

    '模拟按ALT + Printscreen将表格窗口(=图片)复制到

    '剪贴板

    keybd_event VK_LMENU,0,KEYEVENTF_EXTENDEDKEY,0
$
    keybd_event VK_SNAPSHOT,0,KEYEVENTF_EXTENDEDKEY,0
$
    keybd_event VK_SNAPSHOT,0,KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP,0
$
    keybd_event VK_LMENU,0,KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP,0
$
    DoEvents

    '添加名为Temp的工作表

    ThisWorkbook.Worksheets.Add

    ActiveSheet.Name =" Temp"

   设置wshTemp = ThisWorkbook.Worksheets(" Temp")

    '粘贴图片,将打印方向设置为横向打印它。
   使用wshTemp

        .Paste

        .PageSetup.Orientation = xlLandscape

        .PageSetup.Zoom = False

        .PageSetup.FitToPagesWide = 1

        .PageSetup.FitToPagesTall = 1

    '不要在打印输出上打印网格线。
        .PageSetup.PrintGridlines = False


        .PrintOut

   结束与$
    '删除工作表Temp并禁止未保存的警告。

    Application.DisplayAlerts = False

    ThisWorkbook.Worksheets(" Temp")。删除

    Application.DisplayAlerts =真

解决方案
<跨度风格= "字体大小:小"> 。的你好Firstmate,

感谢您的文章

我已经动了你的&NBSP;线程&NBSP; Visual Basic中一般&NBSP;对VBA论坛,因为你的问题与VBA有关。你可以在那里得到更好,更快的支持。感谢您的理解。

最好的问候,

Liliane


I have an Excel document that uses VBA code to organize data. The form i am using has a layout picture that is populated with information. I amtrying to get it to print but the only way i was able to do this is through a print screen and paste command. Well when I first ran the code it worked fine but when I used the document on another computer it does not work. THe error reads that the paste command failed.

 

here is the code

   ' printlogic = False                                          ' sets the print logic to be an internal command
    'PrintFrm (False)                                            ' prints the form

    Dim wshTemp As Worksheet
    DoEvents
    ' Simulate pressing ALT+Printscreen to copy the form window (=picture) to
    ' the clipboard
    keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0
    keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0
    keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
    keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
    DoEvents
    ' Add a worksheet named Temp
    ThisWorkbook.Worksheets.Add
    ActiveSheet.Name = "Temp"
    Set wshTemp = ThisWorkbook.Worksheets("Temp")
    ' Paste the picture, set print orientation to landscape en print it
    With wshTemp
        .Paste
        .PageSetup.Orientation = xlLandscape
        .PageSetup.Zoom = False
        .PageSetup.FitToPagesWide = 1
        .PageSetup.FitToPagesTall = 1
    'Do not print the grid lines on the printout
        .PageSetup.PrintGridlines = False

        .PrintOut
    End With
    ' Delete the worksheet Temp and suppress the not-saved Warning.
    Application.DisplayAlerts = False
    ThisWorkbook.Worksheets("Temp").Delete
    Application.DisplayAlerts = True

解决方案

Hello Firstmate,
Thanks for your post.
I have moved your thread from Visual Basic General to VBA forum because your problem is related to VBA. You could get better and quicker support there. Thanks for your understanding.
Best regards,
Liliane


这篇关于在不同的计算机上使用文档时无法获取粘贴命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆