VBA 最终用户将 Microsoft Office 2007 升级到 2010(VBA 6 到 VBA7)时遇到的问题以及需要文档、帮助和提示。 (关键词就够了)
作为典型的小型企业用户,当我的笔记本电脑坏了时,我必须升级到 Office 2010(2007 版已不再上市)。现在我有一堆快速而肮脏的 VBA 来配合我的旧工作表。它们都不是编程杰作,但它们都可以使用 Excel 和 Office 2007 完成工作。
现在我尝试在 Office 2010 上使用我的旧东西,一切都有点无法使用。我花了两天时间搜索网络,试图为最终用户找到任何文档,但没有成功。我发现了很多针对专业程序员的博客,他们希望编写防弹代码来服务从 Office 0 到 Office2010、32 位到 64 位(这里没有 8 位?)的任何内容,但没有一篇文章谈论主要业务,最终用户需要大量自制编码才能生存一天。
如何使旧的 2007 VBA 与 2010 兼容?
不,我不需要它向后兼容任何东西,它与我的新计算机和新软件兼容就足够了(在我的情况是 64 位,如果有人想知道的话)。我只需要知道为什么我的代码不再工作,以及该怎么办。 我真正想要的是一些指向真实信息的指示(如果有的话)! 当然,我可以将我的每一段代码复制粘贴到程序员讨论论坛上,被嘲笑,几周后我可能会让其中一些代码工作,但我真正需要的是编写给基本 VBA 用户的真实信息。我需要学习这个。
那么您的问题是什么?
发生了什么变化?
日历 Active-X 组件丢失。我找到了解决方案: http://answers.microsoft.com/en-us/office/forum/officeversion_other-customize/missing-calendar-control/03ad5d05-ca3f-4081-9989-e757223ebdde 现在我只是必须重做我所有表格上的每个日历......谢谢。
Textbox.Text 不起作用,我找到并运行 Microsoft Excel 代码兼容性检查器 (CII),它显示我有几千个“已弃用”的 Textbox.Text 元素 – “可能包含对象模型中已删除的项目” - 什么?
它不断变得更好,同样的微软软件指出: “类型:弃用 项目:[xls]SmartTagRecognizer.FullName 网址:http://go.microsoft.com/?linkid=9719761 代码:MyFullName = ThisWorkbook.FullName”” 没有解释…(顺便说一句,停止检查器并查看结果的唯一方法是 CRT-ALT-DEL –停止…)
我访问了检查器给出的链接,没有任何帮助。
我运行检查器几次,每次都会给出不同的结果。现在这很有趣。
我听到了您的问题,现在请告诉我您的问题
我从哪里开始。这是一个。 我有一个表单,用户可以在其中进行新的“约会”,保存时,VBA 在日历工作表中创建一段代码和新形状(以及 Outlook,但这不是这里的重点)。当用户返回并单击该形状 - 按钮 - 按钮时,将运行一段创建的代码。这是代码:
Private Sub myMacro2001_Click()
Dim meetingId As Integer
meetingId = 2001
Load formHours
Call formHours.selectMeeting(meetingId)
formHours.Show vbModeless
End Sub
应该是在 2007 年打开表单 formHours,其中包含为 2001 年会议存储的信息(meetingId)
formHours 中的代码开头为:
Sub selectMeeting (ByRef IdNo As Integer) ’Bring in the meeting ID
Meeting = IdNo
….
不是很优雅,但它有效。不再这样做了。
如果您能帮助我解决这个问题,我很感激,但如果您告诉我应该在哪里找到答案,那就更好了。 发生了什么变化?以前工作过,现在不工作了。该怎么办?
(PS。我知道我的代码很糟糕,但它有效......我只是想知道发生了什么变化,以及我需要如何更改。Ps.Ps
是的,我知道我应该问微软,但你知道怎么做那是……)
跟进
经过 Barrowc 和其他人的一些善意建议后,我设法解决了一些问题。将 Text.Text 更改为 Text.Value 产生了一堆新问题,一些 Text-Values 用于公式,现在我需要更改它们 Val(FooTextBox.Value)
真正令人惊讶的是 2010 年似乎非常慢!我在办公室里同时参加了 2007 年和 2010 年的比赛,2007 年轻松获胜。我的一名员工已经在 2007 年向一位客户开具了发票,当时 2010 年尚未开放!有趣的是,自 2007 年以来,我一直在 AMD Athlon X2 双核处理器上运行,内存有限,而 2010 年,我在我的新笔记本电脑上运行 Core i7-740QM,6 GB,两者都运行 win7-64。我上网查了一下,没有发现任何关于Office 2010上的VBA7比Office2007上的VBA6慢很多的抱怨。我不知道这是否只是我的问题,但我的员工一心一意地投票支持 2007 年......
As typical small-business user, when my laptop broke I HAD to upgrade to Office 2010 (2007 isn’t on market anymore). Now I have a bunch of quick-and-dirty VBA to go with my old worksheets. None of them were programming masterpieces, but those worked and got work done with excel, and office 2007.
Now I tried to use my old stuff on Office 2010, and everything is just little bit off to be usable. For two days I searched web, trying to find any documentation for the end user, no luck. I found a lot of blogs aimed to professional programmers who are hoping to make bullet proof code to serve anything from Office 0 to Office2010, 32 bits to 64 bits (No 8 bits here?), but none of the articles talked about the main business, The End User with whole lot of homemade coding to survive a day.
How do I make my old 2007 VBA to work with 2010?
No, I don’t need it to backwards compatible with anything, it is enough that it works with my new computer, and new software (In my case it is 64 bits, if anyone wonders). I just need to know why my code doesn’t work anymore, and what to do about it.
What I really want is some pointers to real information, if there is any!
Of course I could copy-paste every piece of my code to programmers discussion forums, get laughed at, and after some weeks I might get some of them to work, but what I really need is real information written to basic VBA user. I need to learn this.
So What Is Your Problem?
What has changed?
Calendar active-X component was missing. I found solution: http://answers.microsoft.com/en-us/office/forum/officeversion_other-customize/missing-calendar-control/03ad5d05-ca3f-4081-9989-e757223ebdde now I just have to redo every calendar on all my forms… Thanks.
Textbox.Text wasn’t working, I found and run Microsoft Excel Code Compatibility Inspector (CII), and it showed that I have few thousand of those Textbox.Text elements that are “Deprecated” – “Potentially contains removed items the object model” – What?
It keeps getting better, same Microsoft software stated:
“TYPE: DEPRECATION
ITEM: [xls]SmartTagRecognizer.FullName
URL: http://go.microsoft.com/?linkid=9719761
CODE: MyFullName = ThisWorkbook.FullName””
No explanation… (Btw. only way to stop the Inspector and see the results was CRT-ALT-DEL –Stop…)
I visited the links given by the Inspector, no help there.
I run the Inspector few times, and It gave different results every time. Now that is interesting.
I hear your problem, now show me your problem
Where do I start. Here is one.
I have a form where user can make a new ‘appointment’, when saving, VBA creates piece of code and new Shape into calendar worksheet (and to Outlook, but that is not the point here). When user comes back and clicks that shape – button – Button runs a piece of code that was created. here is the code:
Private Sub myMacro2001_Click()
Dim meetingId As Integer
meetingId = 2001
Load formHours
Call formHours.selectMeeting(meetingId)
formHours.Show vbModeless
End Sub
Which is supposed, and did back in 2007, open up form formHours with information stored for that meeting 2001 (meetingId)
And the code in formHours starts as:
Sub selectMeeting (ByRef IdNo As Integer) ’Bring in the meeting ID
Meeting = IdNo
….
Not very elegant, but it worked. Doesn’t do that anymore.
If you can help me with this case, I appreciate, But it would be even better if you inform me where was I supposed to find the answer.
What has changed? Worked before, doesn’t anymore. What to do?
(PS. I know my code is crappy, but it worked… And I just would like to find out what has changed, and how do I need to change.
Ps.Ps Yes I know I should be asking Microsoft, but you know how that is…)
FOLLOWUP
After some kind advice from Barrowc and others I managed to fix some of problems. Changing Text.Text to Text.Value created bunch of new problems, some of Text-Values were used on formulas, and now I needed to change them Val(FooTextBox.Value)
What is really surprising is that 2010 seems very SLOW! I ran 2007 and 2010 side by side at office, and 2007 won hands down. One of my workers had already invoiced a customer using 2007, when 2010 was still opening up! Funny, since 2007 was running on AMD Athlon X2 Dual-Core with limited memory, and 2010 was on my new laptop with Core i7-740QM, 6 GB, both on win7-64. I surfed the net and didn't find any complaints that VBA7 on Office 2010 is so much slower than VBA6 on Office2007. I don't know if this is just my problem, but my employees voted for 2007 single minded...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于所有
TextBox
实例,将.Text
更改为.Value
SmartTagRecognizer
问题似乎是误报因此无需执行任何操作关于表单错误,您可以尝试以这种方式创建表单以查看是否有帮助:
此外,您可以将
Sub selectMeeting
更改为Public Sub selectMeeting
有关 Office 2007 和 Office 2010 之间 VBA 实际差异的文档似乎有点稀疏。 此页面特别提到 32-位 ActiveX 控件(自定义和内置)在 64 位版本的 Office 2010 中无法工作。因此,这很可能是问题的根源。
还有来自 Microsoft 此处:
(我的重点)
如果可以,请尝试安装到 32 位版本的 Office 2010
For all of your
TextBox
instances change.Text
to.Value
The
SmartTagRecognizer
issue would appear to be a false positive so no action needed thereOn the error with the form, you could try creating the form this way to see if it helps:
Also, you could change
Sub selectMeeting
toPublic Sub selectMeeting
Documentation on the actual differences in VBA between Office 2007 and Office 2010 seems to be a bit sparse. This page specifically mentions that 32-bit ActiveX controls (both custom and built-in) will not work in the 64-bit version of Office 2010. Therefore, this may well be the root of your problem.
There is also a quote from Microsoft here:
(my emphasis)
If you can, try installing to the 32-bit version of Office 2010 instead
我也遇到了问题...几十年来我一直用它来创建一串“=”字符以在文本中进行视觉中断等...
现在人们告诉我该代码在 Excel 2010 中失败。
替换是什么对于上述?我的意思是...我可以做到这一点...
但这确实是一个倒退。
有一个潜在的修复...那就是将其更改为像这样引用 VBA...
它似乎在 2007 年仍然有效。
I am having issues too... for decades I've used this to create a string of "=" characters for a visual break in text etc...
Now people are telling me that the code fails in Excel 2010.
What's the replacement for the above? I mean... I could do this...
but that's a real step backwards.
There is one potential fix... that is to change it to reference VBA like this...
It appeared to still work on 2007.
从@barrowc 获取这一点:
我对此有一个部分解决方案 - 用嵌入图像的形状替换 ActiveX 按钮 - 您需要的一些答案可能位于 我给出的关于伪造“按钮点击”行为的答案
这是一项大量的工作,并且您正在从事件驱动的代码回归到能力较差的对象和过时的对象“分配宏”设计。但您至少可以保持工作表设计的视觉可用性。
Picking up on this point from @barrowc:
I have a partial solution to that - replacing ActiveX buttons with shapes embedding images - and some of the answers you need for that may be in an answer I gave about faking 'button click' behaviour
This is a lot of work, and you're regressing from event-driven code to less-capable objects and an outdated 'assign macro' design. But you can at least maintain the visual usability of your worksheet design.