“无效的过程调用或参数” 设置打印机对象时
我有一个 VB6 应用程序,当程序尝试将 Printer 对象设置为 Printers 集合中的特定打印机时,出现错误 5“无效的过程调用或参数”。 有问题的打印机是通过打印服务器运行的某种复印机/打印机。 将打印机对象设置为集合中定义的其他打印机时,不会发生该错误。 有什么想法可能会导致这种情况下的错误 5 吗? 我不确定在 VB6 中使用“Set Printer = x”语句时到底会发生什么 - 它是否尝试与实际的打印机驱动程序进行交互? 是否有可能由于某种原因驱动程序未被 VB6 打印机对象识别为有效打印机,从而导致“无效参数”错误?
I have a VB6 application that is giving an error 5, "Invalid procedure call or argument" when the program attempts to set the Printer object to a specific printer from the Printers collection. The printer in question is some sort of copier/printer running through a print server. The error doesn't occur when setting the Printer object to other printers defined in the collection. Any ideas what might be causing the error 5 in this circumstance? I'm not sure what exactly happens when using the "Set Printer = x" statement in VB6 - is it attempting to interface with the actual printer driver at that point? Is it possible that the driver isn't recognized as a valid printer by the VB6 Printer object for some reason, resulting in the "invalid argument" error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
“无效的过程调用或参数”是针对 VB 运行时错误 5 的。
我怀疑您看到的错误 5 是 Win32 错误代码,这意味着“访问被拒绝”。
显然 VB 运行时错误与 Win32 错误不同 - 我怀疑它与甚至早于 MS-DOS 的 VB 根源有关: http://blogs.msdn.com/ericlippert/archive/2004/09/09/227461.aspx。 我不确定您应该如何确定何时使用哪种解释
The "Invalid procedure call or argument" is for a VB runtime error 5.
I suspect that the error 5 you're seeing is the Win32 error code, which means "Access is denied".
Apparently VB runtime errors differ from Win32 errors - I suspect that it has to do with the roots of VB predating even MS-DOS: http://blogs.msdn.com/ericlippert/archive/2004/09/09/227461.aspx. I'm not sure how you're supposed to determine which interpretation to use when
您正在使用这样的代码来将其设置正确吗?
不只是试图通过字符串设置它?
为了停止更改默认打印机,您可以在设置打印机之前运行此代码。 然后您就不必重新设置默认打印机。 这也使得您的打印机选择对于您的程序来说是独一无二的,这也是大多数人想要的。
You are using code like this to set it correct?
Not just trying to set it by a string?
In order to stop changing the default printer you run this code before you set the printer. Then you won't have to set the default printer back. This also makes your printer selection unique to your program which is what most people want.
我在 MS Access 2007 VBA 中通过包含服务器名称和打印机名称解决了这个问题。
而不是
希望这对其他人有帮助。
I solved this problem in MS Access 2007 VBA by including the server name along with the printer name.
instead of
Hope this helps someone else.
我遇到了这个错误,经过几个小时的沮丧后找到了我的答案。 这是一个区分大小写的问题。 当我应该使用小写“s”时,我却使用了大写“S”。
所以当代码看起来像这样时:
我会得到错误 5
但是当我将其更改为:
presto 时它就起作用了
I was getting this error and after a couple of hours of frustration found my answer. It was a case sensitive issue. I had a Capital "S" when I should have had a lower case "s".
So when the code looked like this:
I would get error 5
But when I changed it to:
presto it worked
您可能需要查看以下页面:
http://support.microsoft.com/kb/ 322710
每当在 VB6 中打印时,我总是使用此对话框而不是 VB6 附带的通用对话框。 它更可靠。
You may want to take a look at the following page:
http://support.microsoft.com/kb/322710
Whenever printing in VB6 I always use this dialog box instead of the common dialog box that comes with VB6. It is a lot more reliable.