Excel VBE 导出不一致
我正在从 .xls
文件导出 .bas
文件,如下所述:将 VBComponent 代码模块导出到文本文件 以将它们签入 SVN 存储库。
我遇到以下问题,该问题导致文件中变量名称的大小写发生变化,但实际上并不真实(或至少不相关)。
像这样的语句被重新格式化/重新封装:(
rngTenors.Cells(i, 1)
changes into
rngTenors.cells(i, 1)
微妙但仍然不同,它被我使用的 diff 工具拾取,并在生成的噪音中隐藏文件上的真正更改)
任何阻止这种情况发生的方法的想法都会受到赞赏。
I am exporting .bas
files from an .xls
file as outlined here: Exporting A VBComponent Code Module To A Text File to check them in into an SVN repo.
I am encountering the following issue which causes a change in casing of variable names in the files that is actually not real (or at least not relevant).
Statements like these get reformatted/recased:
rngTenors.Cells(i, 1)
changes into
rngTenors.cells(i, 1)
(subtle but still different and it gets picked up by the diff tool that I use and hides the real changes on the file in the noise that this generates)
Any idea of ways to prevent this from happening would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我正在做类似的事情,但还没有看到你所经历的。 我没有使用相同的导出例程,但乍一看它们看起来很相似。
有几个问题。
我只是猜测...但是如果您将变量命名为与方法或属性相同的名称,那么 VB 编辑器的大小写可能会很奇怪。 另外,我不明白为什么您的导出会不一致地导出
.Cell
我猜测如果它导出到.cell
那么它应该始终导出到.cell< /code> 这不是问题。
这些只是一些想法,祝你好运:)
I'm doing something similar but haven't seen what you are experiencing. I'm not using the same export routines but they look similar at first glance.
A couple of questions.
I'm just guessing... but VB editor capitalisation can be weird if you name variables the same as methods or properties. Also i don't see why your export would inconsistently export
.Cell
i'm guessing if it exports to.cell
then it should always export to.cell
and not be a problem.These are just some ideas, good luck :)
VBE 保留变量名称的内部缓存,包括大小写,因此即使您找到一个名为
cell
的变量,并将其重命名为其他名称,VBA 仍然 >认为它是一个有效的名称,因此它在该文本的所有用法中保留大小写。您可以通过临时声明具有正确大小写的变量来欺骗 VBE 重置变量大小写(这也适用于方法上的大小写问题):
然后删除该变量。 然后,您应该发现整个项目(以及引用它的任何项目)中的所有外壳都是固定的。
The VBE keeps an internal cache of variable names, including the casing, so even though you found a variable called
cell
, and renamed it to be something else, VBA still thinks it is a valid name, and so it is preserving the casing across all usages of that text.You can trick the VBE into resetting the variable casing (and this also works for casing problems on methods too) by temporarily declaring a variable with the correct casing:
And then deleting that variable. You should then find that all of the casings are fixed throughout your project (and any project that refers to it).
事实上,我在代码中发现了一些东西,正如上面所建议的。
我现在已重命名该变量,此后没有发生任何重新格式化。 我期待并希望这已经解决了这个问题。 非常感谢您的帮助!
Indeed I found something in the code as was suggested above.
I have now renamed this variable and no reformats have occurred since. I expect and hope that this has resolved the issue. Many thanks for help!