Excel宏在两台计算机上的行为不同 [英] Excel macro is acting differently on two computers

查看:323
本文介绍了Excel宏在两台计算机上的行为不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Excel文件有问题.去年,我对宏进行了编程,以选择绿色作为工作簿中选项卡颜色的所有工作表.直到昨天,所有计算机上的一切都正常运行.实际需要修改该文件的计算机开始采取不同的行动,并且仅选择第一个工作表.我再次卸载并安装了excel,但没有任何改变.我们正在Windows 7 Pro x64和Office 2013家庭及企业版上运行.

I have a problem with an excel file. I programmed a macro last year to select all the worksheets with green as tab color in a Workbook. Everything was working fine on every computers until yesterday. The computer that actually need to modify that file start to act differently and only select the first worksheet. I uninstalled and installed excel again but it did'nt change anything. We're running on Windows 7 Pro x64 with Office 2013 Home and business.

这是我的代码:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    Dim selection As Boolean
    selection = False
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Tab.Color = 5296274 Then
            If selection = False Then
                ws.Select
                selection = True
            Else
                ws.Select (False)
            End If
        End If
    Next

End Sub

谢谢

推荐答案

对我有用的东西-

这是我以前的工作方式:-

Earlier this is how i worked :-

  • 将宏按钮添加到了我的快速访问工具栏
  • 点击按钮以运行宏

始终无缝地工作.直到我重命名模板

Always worked seamlessly. Until I renamed the template

该按钮似乎已硬编码到特定的excel中,并且仅记住为其创建文件的名称

The button seems to be hard-coded into the specific excel, and remembers only the file name for which it was created

因此,如果先前的文件名不存在,它将无法运行. 如果您使用的是以前的文件版本,它将打开该文件并在其上运行宏,从而使您的新输入数据毫无意义

So if the previous file name doesn't exist, it won't run. And if you have the previous file version, it will open that, and run the macro on that, hence making your new input data pointless

这篇关于Excel宏在两台计算机上的行为不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆