ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 1466|回复: 7

[求助] WIN11 无法加载原来excel的VB文件

[复制链接]

TA的精华主题

TA的得分主题

发表于 2022-3-17 19:58 | 显示全部楼层 |阅读模式

新换的电脑,用的是OFFICE 365正版的,老的电脑可以运行,但是新电脑不能运行。
已经将老电脑的相关文件(如MSCOMCT2.OCX等)拷贝到新电脑上,但是还是不可以运行。、
跪求大师指点,万分感谢~~

image.png

TA的精华主题

TA的得分主题

发表于 2022-3-21 15:18 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
你把Module3中的代码贴出来看下,每个版本支持的VB功能范围不太一样,常规的代码基本上都是没问题的,估计是你代码里调用了什么东西在win11不支持,不给代码没法判断

TA的精华主题

TA的得分主题

 楼主| 发表于 2022-3-21 19:43 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
An374938857 发表于 2022-3-21 15:18
你把Module3中的代码贴出来看下,每个版本支持的VB功能范围不太一样,常规的代码基本上都是没问题的,估计 ...

Sub Button4_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "只有Production-C电脑才能更新,请确认是否是Production-C电脑?"  '定义消息文本
Style = vbYesNo + vbCritical + vbDefaultButton2    ' 定义按钮
Title = "MsgBox Demonstration"    ' 定义标题文本
Help = "DEMO.HLP"    ' 定义帮助文件
Ctxt = 1000    ' 定义帮助主题
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then    ' 用户按下“是”
    MyString = "Yes" ' 完成某操作
   
    GoTo 104
Else    ' 用户按下“否”
    MyString = "No"    ' 完成某操作
    GoTo 86
End If

104

Call Macro3
Call hqq
Call Macro4

UserForm1.Show
86

End Sub
Sub Button7_Click()
Call hqq
UserForm1.Show
End Sub
Sub Button8_Click()
Call hqq
UserForm2.Show
End Sub

Private Sub hqq()

Worksheets(2).Range("A2:J1048576").Interior.Color = RGB(255, 255, 255)



    Dim s As New Collection, arr, rng As Range
    Dim a As Integer
    Dim i As Integer
    a = Worksheets(5).[a65536].End(xlUp).Row
    For Each rng In Worksheets(5).Range("A2:A" & a)
        If rng <> "" Then s.Add rng, CStr(rng)
    On Error Resume Next
      
    Next
    ReDim arr(1 To s.Count)
    For i = 1 To s.Count
        arr(i) = s(i)
    Next
    UserForm1.ComboBox2.List = arr
    UserForm2.ComboBox3.List = arr
   
   
     Dim s1 As New Collection, arr1, rng1 As Range
    Dim a1 As Integer
    Dim I1 As Integer
    a1 = Worksheets(7).[c65536].End(xlUp).Row
    For Each rng1 In Worksheets(7).Range("c3:c" & a1)
        If rng1 <> "" Then s1.Add rng1, CStr(rng1)
        
        
        
    Next
   
    ReDim arr1(1 To s1.Count)
    For I1 = 1 To s1.Count
        arr1(I1) = s1(I1)
        
    Next
   
    UserForm2.ComboBox5.List = arr1
    UserForm2.ComboBox7.List = arr1
    UserForm2.ComboBox11.List = arr1
   
   
   
    Dim s2 As New Collection, arr2, rng2 As Range
    Dim a2 As Integer
    Dim I2 As Integer
    a2 = Worksheets(7).[e65536].End(xlUp).Row
    For Each rng2 In Worksheets(7).Range("E3:E" & a2)
        If rng2 <> "" Then s2.Add rng2, CStr(rng2)
    Next
    ReDim arr2(1 To s2.Count)
    For I2 = 1 To s2.Count
        arr2(I2) = s2(I2)
    Next
   
    UserForm2.ComboBox9.List = arr2
   
   
    Dim s3 As New Collection, arr3, rng3 As Range
    Dim a3 As Integer
    Dim i3 As Integer
    a3 = Worksheets(2).[e65536].End(xlUp).Row
    For Each rng3 In Worksheets(2).Range("E3:E" & a3)
        If rng3 <> "" Then s3.Add rng3, CStr(rng3)
    Next
    ReDim arr3(1 To s3.Count)
    For i3 = 1 To s3.Count
        arr3(i3) = s3(i3)
    Next
   
    UserForm2.ComboBox12.List = arr3
    UserForm3.ComboBox14.List = arr3
    UserForm1.ComboBox3.List = arr3  'add 8-Aug-16
   
   
   
   
    today = Worksheets(1).Range("d5").Value
   
    UserForm2.DTPicker1 = today
    UserForm2.DTPicker2 = today
    UserForm2.DTPicker3 = today
    UserForm2.DTPicker4 = today
    UserForm2.DTPicker5 = today
    UserForm2.DTPicker6 = today
   
    UserForm2.Frame3.Visible = False
    UserForm2.Frame4.Visible = False
    UserForm2.Frame5.Visible = False
    UserForm2.Frame6.Visible = False

End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2022-3-21 19:44 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
An374938857 发表于 2022-3-21 15:18
你把Module3中的代码贴出来看下,每个版本支持的VB功能范围不太一样,常规的代码基本上都是没问题的,估计 ...

Sub Button4_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "只有Production-C电脑才能更新,请确认是否是Production-C电脑?"  '定义消息文本
Style = vbYesNo + vbCritical + vbDefaultButton2    ' 定义按钮
Title = "MsgBox Demonstration"    ' 定义标题文本
Help = "DEMO.HLP"    ' 定义帮助文件
Ctxt = 1000    ' 定义帮助主题
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then    ' 用户按下“是”
    MyString = "Yes" ' 完成某操作
   
    GoTo 104
Else    ' 用户按下“否”
    MyString = "No"    ' 完成某操作
    GoTo 86
End If

104

Call Macro3
Call hqq
Call Macro4

UserForm1.Show
86

End Sub
Sub Button7_Click()
Call hqq
UserForm1.Show
End Sub
Sub Button8_Click()
Call hqq
UserForm2.Show
End Sub

Private Sub hqq()

Worksheets(2).Range("A2:J1048576").Interior.Color = RGB(255, 255, 255)



    Dim s As New Collection, arr, rng As Range
    Dim a As Integer
    Dim i As Integer
    a = Worksheets(5).[a65536].End(xlUp).Row
    For Each rng In Worksheets(5).Range("A2:A" & a)
        If rng <> "" Then s.Add rng, CStr(rng)
    On Error Resume Next
      
    Next
    ReDim arr(1 To s.Count)
    For i = 1 To s.Count
        arr(i) = s(i)
    Next
    UserForm1.ComboBox2.List = arr
    UserForm2.ComboBox3.List = arr
   
   
     Dim s1 As New Collection, arr1, rng1 As Range
    Dim a1 As Integer
    Dim I1 As Integer
    a1 = Worksheets(7).[c65536].End(xlUp).Row
    For Each rng1 In Worksheets(7).Range("c3:c" & a1)
        If rng1 <> "" Then s1.Add rng1, CStr(rng1)
        
        
        
    Next
   
    ReDim arr1(1 To s1.Count)
    For I1 = 1 To s1.Count
        arr1(I1) = s1(I1)
        
    Next
   
    UserForm2.ComboBox5.List = arr1
    UserForm2.ComboBox7.List = arr1
    UserForm2.ComboBox11.List = arr1
   
   
   
    Dim s2 As New Collection, arr2, rng2 As Range
    Dim a2 As Integer
    Dim I2 As Integer
    a2 = Worksheets(7).[e65536].End(xlUp).Row
    For Each rng2 In Worksheets(7).Range("E3:E" & a2)
        If rng2 <> "" Then s2.Add rng2, CStr(rng2)
    Next
    ReDim arr2(1 To s2.Count)
    For I2 = 1 To s2.Count
        arr2(I2) = s2(I2)
    Next
   
    UserForm2.ComboBox9.List = arr2
   
   
    Dim s3 As New Collection, arr3, rng3 As Range
    Dim a3 As Integer
    Dim i3 As Integer
    a3 = Worksheets(2).[e65536].End(xlUp).Row
    For Each rng3 In Worksheets(2).Range("E3:E" & a3)
        If rng3 <> "" Then s3.Add rng3, CStr(rng3)
    Next
    ReDim arr3(1 To s3.Count)
    For i3 = 1 To s3.Count
        arr3(i3) = s3(i3)
    Next
   
    UserForm2.ComboBox12.List = arr3
    UserForm3.ComboBox14.List = arr3
    UserForm1.ComboBox3.List = arr3  'add 8-Aug-16
   
   
   
   
    today = Worksheets(1).Range("d5").Value
   
    UserForm2.DTPicker1 = today
    UserForm2.DTPicker2 = today
    UserForm2.DTPicker3 = today
    UserForm2.DTPicker4 = today
    UserForm2.DTPicker5 = today
    UserForm2.DTPicker6 = today
   
    UserForm2.Frame3.Visible = False
    UserForm2.Frame4.Visible = False
    UserForm2.Frame5.Visible = False
    UserForm2.Frame6.Visible = False

End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2022-3-21 19:48 | 显示全部楼层
An374938857 发表于 2022-3-21 15:18
你把Module3中的代码贴出来看下,每个版本支持的VB功能范围不太一样,常规的代码基本上都是没问题的,估计 ...

Sub Button4_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "只有Production-C电脑才能更新,请确认是否是Production-C电脑?"  '定义消息文本
Style = vbYesNo + vbCritical + vbDefaultButton2    ' 定义按钮
Title = "MsgBox Demonstration"    ' 定义标题文本
Help = "DEMO.HLP"    ' 定义帮助文件
Ctxt = 1000    ' 定义帮助主题
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then    ' 用户按下“是”
    MyString = "Yes" ' 完成某操作
   
    GoTo 104
Else    ' 用户按下“否”
    MyString = "No"    ' 完成某操作
    GoTo 86
End If

104

Call Macro3
Call hqq
Call Macro4

UserForm1.Show
86

End Sub
Sub Button7_Click()
Call hqq
UserForm1.Show
End Sub
Sub Button8_Click()
Call hqq
UserForm2.Show
End Sub

Private Sub hqq()

Worksheets(2).Range("A2:J1048576").Interior.Color = RGB(255, 255, 255)



    Dim s As New Collection, arr, rng As Range
    Dim a As Integer
    Dim i As Integer
    a = Worksheets(5).[a65536].End(xlUp).Row
    For Each rng In Worksheets(5).Range("A2:A" & a)
        If rng <> "" Then s.Add rng, CStr(rng)
    On Error Resume Next
      
    Next
    ReDim arr(1 To s.Count)
    For i = 1 To s.Count
        arr(i) = s(i)
    Next
    UserForm1.ComboBox2.List = arr
    UserForm2.ComboBox3.List = arr
   
   
     Dim s1 As New Collection, arr1, rng1 As Range
    Dim a1 As Integer
    Dim I1 As Integer
    a1 = Worksheets(7).[c65536].End(xlUp).Row
    For Each rng1 In Worksheets(7).Range("c3:c" & a1)
        If rng1 <> "" Then s1.Add rng1, CStr(rng1)
        
        
        
    Next
   
    ReDim arr1(1 To s1.Count)
    For I1 = 1 To s1.Count
        arr1(I1) = s1(I1)
        
    Next
   
    UserForm2.ComboBox5.List = arr1
    UserForm2.ComboBox7.List = arr1
    UserForm2.ComboBox11.List = arr1
   
   
   
    Dim s2 As New Collection, arr2, rng2 As Range
    Dim a2 As Integer
    Dim I2 As Integer
    a2 = Worksheets(7).[e65536].End(xlUp).Row
    For Each rng2 In Worksheets(7).Range("E3:E" & a2)
        If rng2 <> "" Then s2.Add rng2, CStr(rng2)
    Next
    ReDim arr2(1 To s2.Count)
    For I2 = 1 To s2.Count
        arr2(I2) = s2(I2)
    Next
   
    UserForm2.ComboBox9.List = arr2
   
   
    Dim s3 As New Collection, arr3, rng3 As Range
    Dim a3 As Integer
    Dim i3 As Integer
    a3 = Worksheets(2).[e65536].End(xlUp).Row
    For Each rng3 In Worksheets(2).Range("E3:E" & a3)
        If rng3 <> "" Then s3.Add rng3, CStr(rng3)
    Next
    ReDim arr3(1 To s3.Count)
    For i3 = 1 To s3.Count
        arr3(i3) = s3(i3)
    Next
   
    UserForm2.ComboBox12.List = arr3
    UserForm3.ComboBox14.List = arr3
    UserForm1.ComboBox3.List = arr3  'add 8-Aug-16
   
   
   
   
    today = Worksheets(1).Range("d5").Value
   
    UserForm2.DTPicker1 = today
    UserForm2.DTPicker2 = today
    UserForm2.DTPicker3 = today
    UserForm2.DTPicker4 = today
    UserForm2.DTPicker5 = today
    UserForm2.DTPicker6 = today
   
    UserForm2.Frame3.Visible = False
    UserForm2.Frame4.Visible = False
    UserForm2.Frame5.Visible = False
    UserForm2.Frame6.Visible = False

End Sub

TA的精华主题

TA的得分主题

发表于 2022-3-22 10:51 | 显示全部楼层
这个按理跟Windows版本关系不大,检查下 Excel 版本是否一致,包括是32位还是64位

TA的精华主题

TA的得分主题

 楼主| 发表于 2022-3-22 12:37 | 显示全部楼层
lele6809 发表于 2022-3-22 10:51
这个按理跟Windows版本关系不大,检查下 Excel 版本是否一致,包括是32位还是64位

原来电脑excel是32位的,现在电脑中excel是64位的

TA的精华主题

TA的得分主题

发表于 2022-3-22 13:15 | 显示全部楼层
china-sz 发表于 2022-3-22 12:37
原来电脑excel是32位的,现在电脑中excel是64位的

感觉跟这个关系较大,新电脑最好改成32位Excel
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2025-1-12 15:47 , Processed in 0.025844 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表