控制 Word 的 VB6 应用程序在调试期间的行为与编译时的行为不同
我有一个 vb6 应用程序,它使用 Word 互操作来创建一些报告。在这些报告的介绍中,图像周围的 4 个文本框中有一些说明。
最近,突然前两个文本框开始出现在下一页上,我不明白为什么。当我单步执行代码并观察 Word 文档的构建时,一切都正确定位,但是,如果我编译应用程序,错误就会再次出现。
有什么建议吗?
I have a vb6 app that uses Word interop to create a few reports. In the introduction of these reports, there are some instructions in 4 textboxes around an image.
Recently and suddenly the top two textboxes started appearing on the next page, and I can't figure out why. When I step through the code and watch the word document getting built, everything positions itself correctly, however, if I compile the application, the error reappears.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用对 Word 的后期绑定调用。这并不意味着删除对
Microsoft Word Xxx Object Library
的引用,只需像这样更改您的Dim
Use late-bound calls to Word. This does not mean to remove reference to
Microsoft Word Xxx Object Library
, just alter yourDim
s like this这可能是一些“四舍五入”的差异吗?例如,如果您比较 浮点 值http://floating-point-gui.de/errors/comparison/" rel="nofollow">相等,结果可能微妙地取决于特定的编译器/解释器实现。
我想建议将代码缩减到最少,以显示不同的行为。这可能已经澄清了事情。如果没有,请将其发布在这里,让我们为您提供帮助。
Could it be some 'rounding' difference? For instance if you compare two float point values for equality, the result can subtly depend on the specific compiler/interpreter implementation.
I would like to suggest to trim down your code to the minimum showing the different behaviors. That might clear things up already. If not, please post it here to let us help you.
也许您在调试时以与运行 VB 的用户不同的用户身份运行编译版本?如果两个用户有一些不同的 Word 设置,这可能会导致您所描述的情况。
编译版本是否有可能找到不同版本的 .dot 文件?
如果您展示用于创建 Word 文档的代码,这可能会非常有帮助,因为这样这里的人可能会注意到一些对于移动到编译版本来说可能是明智的。
Maybe you are running the compiled version as a different user than the one running VB when you debug? Maybe this could cause what you are describing, if the two users have some different Word settings.
Is it possible that the compiled version finds a different version of the .dot file?
It may be very helpful if you show the code you use to create the Word document, because then someone here might notice something that can be sensible to moving to a compiled version.
您在依赖计时的事件(例如 Form_Activate、Load 或 Unload)中是否有任何代码?我发现这些东西在单步执行代码和编译时的行为非常不同,特别是在更新、更快的机器上。
Do you have any code in events that rely on timing, such as Form_Activate, Load, or Unload? I've seen those things behave very differently when stepping through code and when compiled, especially on newer, faster machines.