编译错误;找不到方法或数据

时间:2017-02-09 04:45:16

标签: vba excel-vba vb6 excel

以下代码在笔记本电脑上工作正常,但在我的办公室桌面上我无法运行该程序。错误是找不到方法或数据。 请给我一个解决方案。

Private Sub cmdGenRep_Click()

Private Sub Form_Load()
    sbStatusBar.Panels(1).Text = "Developed by: xxx"
    sbStatusBar.Panels(2).Text = "Ver: " & App.Major & "." & App.Minor & "." & App.Revision
    tabSales.Tab = 0
    OptQReg.Value = True

    cboMonth.AddItem "January"
    cboMonth.AddItem "February"
    cboMonth.AddItem "March"
    cboMonth.AddItem "April"
    cboMonth.AddItem "May"
    cboMonth.AddItem "June"
    cboMonth.AddItem "July"
    cboMonth.AddItem "August"
    cboMonth.AddItem "September"
    cboMonth.AddItem "October"
    cboMonth.AddItem "November"
    cboMonth.AddItem "December"

    cboMonth.ListIndex = Val(Format(Date, "mm")) - 1
    txtYear = Format(Date, "YYYY")

    Dim Tdate As String
    Dim Fdate As Date
    Tdate = "01/" & Format(Date, "MMM/YY")
    Fdate = Format(Tdate, "DD/MMM/YY")
    optQRep.Value = True
    optComp.Value = True
    optEntry.Value = True
    DTPstDate.Value = Fdate
    DTPEndDate.Value = Format(Date, "DD/MMM/YY")

    cboScope.AddItem "ALL"
    cboScope.AddItem "STEEL+CLADDING"
    cboScope.AddItem "CLADDING ONLY"
    cboScope.AddItem "STEEL ONLY"
    cboScope.ListIndex = 0

    pathTmpl = "C:\templates\"
    pathQregister = "C:\register\"
    pathJobRegister = "C:\register\"

End Sub

1 个答案:

答案 0 :(得分:0)

您的问题可能与excel版本的兼容性问题有关。以下是更改状态栏文本并在脚本完成时将其恢复为原始文件的可靠方法

sub statusBarChange()
   oldStatusBar = Application.DisplayStatusBar 
   Application.DisplayStatusBar = True 
   Application.StatusBar = "Please be patient..." 
   Workbooks.Open filename:="LARGE.XLS" 
   Application.StatusBar = False 
   Application.DisplayStatusBar = oldStatusBar
end sub

来自:Microsoft.Com