VBA错误4198“运行时错误";带粘贴 [英] VBA Error 4198 "Runtime Error" With Paste
问题描述
我一直试图编写一个使用截图(已经复制到剪贴板)的Word VBA脚本,并将其粘贴到Word文档中以进行格式化和保存.该程序在我正在工作的计算机上运行良好,但是当我将其分发给其他人时,它无法在大约25%的计算机上运行.我收到的错误是"4198 Runtime Error".我一直在寻找其他人也遇到过的类似问题,但我仍然茫然.办公室中的所有计算机都运行相同的工作版本,即2010标准版本.
I have been trying to write a word VBA script that uses a screenshot (already copied to the clipboard) and pastes it into a word document to be formatted and saved. The program works great on my computer at work, but when I distributed it to others, it failed to work on about 25% of the computers. The error that I received was "4198 Runtime Error". I have searched for similar problems that other people have had, but I am still at a loss. All of the computers in the office run the same version of work, 2010 standard version.
问题出在代码的最后一行,selection.paste. 在运行脚本之前,我确实确保他们的剪贴板上有屏幕截图.
The issue is with the very last line of code, selection.paste. I did make sure that they had a screenshot on their clipboard before running the script.
非常感谢您提供的所有信息.
Thank you so much for any and all input.
Sub MapMaker()
'set up new document with narrow margins and landscape orientation
With Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.5)
.BottomMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
If Selection.PageSetup.Orientation = wdOrientPortrait Then
Selection.PageSetup.Orientation = wdOrientLandscape
Else
Selection.PageSetup.Orientation = wdOrientPortrait
End If
' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'paste and resize screenshot to full page width
Selection.Paste
推荐答案
4198运行时错误可能与链接相关联.如果您的原始Word文档上有要打印的链接,请尝试将其删除,看看是否可以解决问题.
4198 Runtime Error might associate with links. If you have links on your origin word document where it is being printscreened, try remove it and see if that solve the problem.
这篇关于VBA错误4198“运行时错误";带粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!