精华内容
下载资源
问答
  • VBA错误处理语句

    2021-05-14 16:03:30
    resume y: 或 resume next 或resume //处理错误之后,执行什么动作 on error go to x,发生错误跳到x:执行 exit sub ,防止无错误也执行 resume y: 跳到y处执行 resume next 继续执行发生错误处的下一句 resume ...

    on error go to  x

    正常代码

    exit sub

    x:

    错误处理代码

    resume y: 或 resume next 或resume  //处理错误之后,执行什么动作

    • on error go to x,发生错误跳到x:执行
    • exit sub ,防止无错误也执行
    • resume y: 跳到y处执行
    • resume next 继续执行发生错误处的下一句
    • resume 继续执行发生错误的语句
    • on error resume next 与 on error go to 0搭配,表示resume next错误忽略的范围至 on error go  to 0结束
    展开全文
  • VBA错误处理

    2021-08-28 12:20:46
    VBA错误处理相关

    VBA错误的三种类型

    • 语法错误:输入代码不符合VBA编写规范;
    • 运行时错误:程序运行时发生的错误;
    • 逻辑错误:语法和运行都没问题,结果不正确;

    这里讲的错误主要是运行时的错误;

    错误捕获和处理
    VBA中使用On Error语句捕获错误,该语句用于启动一个错误处理程序并指定该子程序在一个过程中的位置,或者用来禁止一个错误处理程序。
    如果不使用On Error语句,运行时的任何错误都会显示错误信息、终止程序;
    错误处理程序依靠Err对象的Number属性中的值来确定错误发生的原因;在其他任何错误发生之前,或在调用一个可能会导致错误发生的过程之前,错误处理程序应该先测试或存储Err对象中相关的属性值。Err对象中的属性值只反映最近发生的错误。Err.Description中包含有与Err.Number相关联的错误信息。
    Err.Number值介绍:
    Err.Number

    引用Err对象等同于访问Err.Number属性,MsgBox ErrMsgBox Err.Number是等同的;

    On Error语句

    • On Error GoTo line:
      启动错误处理程序,如果发生一个运行时错误,则会跳到line标号处开始执行错误处理程序。标号line必须位于与On Error语句相同的过程中,否则会发生编译时间错误。这个line也可以是其他命名;
    sub test()
    on error goto line1:
    debug.print "do something"
    line1:     ' 程序如果遇到错误,跳转到该位置往下运行
    debug.print "do other things"
    end sub
    

    案例:打开工作簿处理

    Function workbook_open(file_path As String)
    ' 打开工作簿
    Dim wb As Workbook
    On Error Resume Next   ' 遇到错误,跳过
    Set wb = Workbooks.Open(file_path)
    
    If Err <> 0 Then   ' 如果打开工作簿报错,直接结束程序,不运行下面代码
        Exit Function
    End If
    Debug.Print "处理工作表的其他逻辑"
    End Sub
    
    • On Error Resume Next:
      如果一个运行时错误发生,程序会转到发生错误语句的下一条语句,并在此继续运行。访问对象时要使用这种形式而不使用On Error GoTo。类似于python总的pass.
    sub deal_err()
    on error resume next
    debug.print "do something"
    ' 这段代码,如果报错,继续错误后下一条代码运行
    if err <> 0:
    	debug.print "如果遇到错误,可以在这里添加一点错误处理程序"
    end if
    on error goto 0   ''结束异常处理,下面语句如果遇到错误,会抛出错误信息,终止程序,这个0不会跳转,表示结束;
    debug.print "do other things"
    end sub
    
    # python
    try:
    	print("do something")
    	num = 1 / 0
    except Exception as e:
    	pass    # 跳过错误继续运行下一条语句
    
    • On Error GoTo 0:
      禁止当前过程中任何已启动的错误处理程序。如果没有On Error GoTo 0语句,则在退出过程时,错误处理程序会自动关闭。

    在错误未发生时,为了防止错误处理程序代码继续运行,一般在紧靠着错误处理程序的前面写入ExitSub、Exit Function或Exit Property语句。

    Resume语句

    • Resume:
      如果错误和错误处理程序出现在同一个过程中,则从产生错误的语句处恢复运行。如果错误出现在被调用的过程中,则从最近一次调用包含错误处理程序的过程的语句处恢复运行。
    • Resume Next:
      如果错误和错误处理程序出现在同一个过程中,则从紧随着产生错误的语句的下一个语句处恢复运行。如果错误发生在被调用的过程中,则找出最后一次调用包含错误处理程序的过程的语句(或On ErrorResume Next语句),从紧随该语句之后的语句处恢复运行。
    • Resume line:
    • 错误处理程序运行结束后,跳转到标号line处恢复运行。line必须和错误处理程序在同一个过程中。

    非代码内容提炼自《精通Excel VBA》- 伍云辉

    展开全文
  • vba 错误 自动化错误Much of our world today relies increasingly on automated solutions. The results often enrich our lives by enabling workers to spend less time on manual tasks and more time for ...

    vba 错误 自动化错误

    Much of our world today relies increasingly on automated solutions. The results often enrich our lives by enabling workers to spend less time on manual tasks and more time for creativity, innovation, and enjoyment.

    今天,我们世界上的许多人越来越依赖自动化解决方案。 通过使工作人员减少在手动任务上的时间,而将更多的时间用于创造力,创新和娱乐上,结果通常可以丰富我们的生活。

    Particularly relevant is the current push towards development of contact-tracing apps and other solutions that could help all of us take steps to protect our health, and that of our loved ones, while benefitting from as full and rich a life as possible. Tempted by the rewards offered by automated solutions, all of us, perhaps especially software developers and technology entrepreneurs, are susceptible to some of these common traps.

    特别重要的是,当前正在努力开发接触式跟踪应用程序和其他解决方案,这些解决方案可以帮助我们所有人保护自己和亲人的健康,同时尽可能地享受充实和丰富的生活。 受到自动化解决方案提供的奖励的诱惑,我们所有人,尤其是软件开发人员和技术企业家,都容易受到其中一些常见陷阱的影响。

    Automation for its own sake

    自动化本身

    When do we do it?

    我们什么时候做?

    This can happen when we become frustrated with a manual process that is part of our everyday lives. Perhaps a friend, colleague, or favourite online influencer has been boasting about their automation successes. We know that, when used appropriately, automation can assist humans with well understood but laborious tasks, freeing us up to tackle more complex problems. It’s understandably tempting for any individual or business adopting a tool or approach with a good reputation to assume it will bring great benefits and jump right into using it, regardless of whether it truly applies to our use case.

    当我们对日常生活中的手动过程感到沮丧时,就会发生这种情况。 也许朋友,同事或最喜欢的在线影响者一直吹嘘他们的自动化成功。 我们知道,如果使用得当,自动化可以帮助人们完成众所周知但费力的任务,使我们有更多的精力去解决更复杂的问题。 可以理解的是,任何个人或企业都采用具有良好声誉的工具或方法,认为它会带来巨大的好处并立即使用它,而不论它是否真正适用于我们的用例。

    Why shouldn’t we do it?

    我们为什么不应该这样做呢?

    When we don’t have a clearly defined problem, or we can’t really explain why the tool or process we want to use will help us solve our problem or meet our goals more efficiently, the most likely outcome is that we end up with two problems; the still sub-optimal status quo, and the added complexity of the new “solution” that didn’t actually help. Instead of accepting that automation didn’t have the miraculous results we’d hoped for, many of us are tempted to “double down” and continue to try to make the new shiny thing work as well as we want it to (see the next section on “silver bullet” syndrome).

    当我们没有明确定义的问题,或者我们无法真正解释为什么我们要使用的工具或流程可以帮助我们解决问题或更有效地实现目标时,最有可能的结果就是我们最终两个问题; 仍然不理想的现状,以及新的“解决方案”的复杂性实际上并没有帮助。 我们中的许多人不但没有接受自动化并没有取得我们希望的奇迹般的结果,反而很想“加倍努力”,并继续尝试使新的闪亮事物按我们希望的那样工作(请参阅下一篇) “银弹”综合症部分)。

    What are the consequences?

    有什么后果?

    For several years, Elon Musk’s approach to manufacturing the iconic and expensive Tesla car was a high-profile example of automation for its own sake. Musk’s dream of a futuristic, fully automated process was proven to have more style than substance when it repeatedly led to production below 50% of targets. Despite significant improvements, financial analysts have remained sceptical about Tesla’s ability to align production numbers with their valuation. Musk’s tendency to automate for its own sake also failed spectacularly in 2018 when his apparently altruistic but arguably over-engineered attempt to rescue a cave-trapped group of children and their coach was politely rebuffed in favour of a manual rescue operation led by experienced divers. While it’s not the worst suggestion Musk made during the emergency, one could argue that his impulse to over-automate appears to have caused more problems in his business than it has solved.

    多年来,埃隆·马斯克(Elon Musk)制造标志性且昂贵的特斯拉汽车的方法本身就是自动化的备受瞩目的例子。 当马斯克一再导致产量低于目标的50%时,马斯克梦想的一种具有未来主义意义的,完全自动化的过程将具有更多的风格。 尽管取得了重大进步,但金融分析师仍对特斯拉能否将生产数量与估值保持一致持怀疑态度 。 马斯克为自己的利益实现自动化的趋势在2018年也以失败告终,当时他显然是无私的,但可以说是过度设计的尝试来挽救一群被困在洞穴中的儿童 ,他们的教练被礼貌地拒绝了,转而支持由经验丰富的潜水员领导的手动救援行动。 尽管这不是马斯克在紧急情况下提出的最糟糕的建议 ,但有人可以辩称,他过度自动化的冲动似乎给他的业务造成了比解决的问题更多的问题。

    How do we avoid it?

    我们如何避免呢?

    Listen to the words you use when you pitch an automated solution to someone else. Are you clearly outlining a problem or inefficiency that you have, and a potential solution, or are you simply praising the solution’s popularity, proponents, or elegance in general terms?

    将自动解决方案推销给其他人时,请听您使用的词语。 您是否清楚地概述了存在的问题或效率低下以及可能的解决方案,还是只是在总体上称赞该解决方案的受欢迎程度,拥护者或优雅?

    Don’t say: Python_Rockstar82, clever developer person, use build tool. Me use build tool also, be rock star too.

    不要说:聪明的开发人员Python_Rockstar82,使用构建工具。 我也使用构建工具,也是摇滚明星。

    Do say: We’re losing a lot of development time due to inconsistencies in our build scripts. Each app has to be updated manually every time we become aware of a security vulnerability or simply find a better approach. I think we could save a lot of time and increase the stability of our applications if we create a command line interface that updates our scripts to the latest template.

    请说:由于我们的构建脚本不一致,我们浪费了很多开发时间。 每当我们意识到安全漏洞或只是找到更好的方法时,必须手动更新每个应用程序。 我认为,如果我们创建一个将脚本更新为最新模板的命令行界面,则可以节省大量时间并提高应用程序的稳定性。

    Seeing automated solutions as “silver-bullets” that can act alone

    将自动化解决方案视为 可以单独行动的 银子弹

    When do we do it?

    我们什么时候做?

    We’re are arguably at highest risk of this syndrome when we’ve learned just enough about an automated tool or approach to become convinced it will improve productivity and / or reduce costs. Unfortunately, at this point, we have no solid evidence that this is the case, but end up rolling it out across the business anyway in the hopes that results will reward our confidence. This often results in expectations far greater than the tool or process can ever provide. Early successes with prototypes and general enthusiasm about a solution can lead us to stop evaluating and improving the process, or even bothering to sufficiently train ourselves and others on how it works. Letting the machine take care of itself frees up humans for more creative and communications-based tasks and exploration of new ideas.

    当我们对自动工具或方法了解得足够多,使我们确信该工具或方法将提高生产率和/或降低成本时,我们面临这种综合征的风险最高。 不幸的是,在这一点上,我们没有确凿的证据证明确实如此,但是最终还是将其推广到整个企业,希望结果能回报我们的信心。 这常常导致期望远远超过工具或过程所能提供的期望。 原型的早期成功和对解决方案的普遍热情可能导致我们停止评估和改进过程,甚至不愿对自己和他人进行充分的培训。 让机器自己照顾自己可以使人们腾出更多精力进行更具创意和基于交流的任务,并探索新的思想。

    Why shouldn’t we do it?

    我们为什么不应该这样做呢?

    Any automated solution is only good as its design and training. Demonstrations of prototypes applied to limited use cases are often impressive, but widely rolling out an automated system without a plan for its ongoing evaluation, maintenance, and monitoring can result in the organisation working for the machine, rather than the other way around. If you don’t understand the extent of what your tool does, or why it’s doing it, then the tool doesn’t really know either. At that point, identifying and solving problems can become a colossal task.

    任何自动化解决方案都只有其设计和培训才能发挥作用。 应用于有限用例的原型的演示通常令人印象深刻,但是如果在没有计划进行持续评估,维护和监视的情况下广泛部署自动化系统,则会导致组织为机器工作,而不是相反。 如果您不了解工具的功能范围或执行原因,那么该工具也不知道。 到那时,识别和解决问题可能成为一项艰巨的任务。

    What are the consequences?

    有什么后果?

    US IT contractor Ibrahim Diallo was mistakenly terminated, locked out of every system he could access, and even escorted from the building by security because his former manager had failed to renew his contract. Ibrahim reported that it took the company three weeks to figure out that their own software appeared to have triggered these events without any human understanding how or why. It’s hard to say what the exact cost of this mistake was, but, it appears that through over-reliance on their automated systems to manage themselves, this organisation ended up suspending the activities of a skilled professional for the better part of a month, taking other staff away from their duties to rectify the problem, and suffering morale and reputational damage.

    美国IT承包商易卜拉欣·迪亚洛(Ibrahim Diallo)错误地终止了工作 ,被他可以访问的每个系统都锁定了,甚至由于安全原因而被护送出大楼,因为他的前任经理未能续签合同。 易卜拉欣报道说,公司花了三周的时间才弄清楚他们自己的软件似乎触发了这些事件,而没有任何人类了解如何或为什么。 很难说出这个错误的确切代价是什么,但是,看来,由于过度依赖他们的自动化系统来管理自己,这个组织最终暂停了熟练技术人员的活动,为期一个月的大部分时间,其他员工则无法纠正问题,并士气和声誉受到损害。

    How do we avoid it?

    我们如何避免呢?

    Be cautious in any new implementation, ideally rolling it out to a small group first. Monitor its effectiveness against pre-defined metrics, such as time spent debugging, number of manual tasks that require developer time, or bug reports that reference regressions or inconsistencies between systems. Always have a defined fallback plan in the event you don’t like what the numbers are telling you.

    在任何新实施中都要谨慎,最好先将其推广到一个小组。 根据预定义的指标(例如花费的调试时间,需要开发人员时间的手动任务数量或引用系统之间的回归或不一致的错误报告)来监视其有效性。 如果您不喜欢数字告诉您的内容,请务必制定定义的后备计划。

    Don’t say: I read an article that advocated a fully automated pipeline with no manual approval step. I’m sick of having to wait to get code that has passed all of our tests out to users. Let’s immediately remove the manual step for all of our apps and spend the savings we’re bound to make on an office treehouse.

    不要说:我读过一篇文章,提倡全自动流水线,无需人工批准。 我讨厌不得不等待获得将所有测试传递给用户的代码。 让我们立即删除所有应用程序的手动步骤,然后将节省下来的钱花在办公室树屋上

    Do say: We are going to try a fully automated pipeline for our most mature and well understood application for one month. If all automated tests pass in the staging environment, the pipeline will deploy automatically to production with no human intervention. During this time, we will compare our bug reports and production incident statistics with the previous month, which required a human to approve promotion of a release to production. We will also evaluate the difference in how developers and test engineers use their time to see if this could be a beneficial approach for all of our applications. If it doesn’t go well, switching the manual approval step back on is a thirty second job.

    请说:我们将为我们最成熟,最容易理解的应用程序尝试一个全自动管道,为期一个月。 如果所有自动化测试都在过渡环境中通过,则管道将自动部署到生产中,而无需人工干预。 在此期间,我们将把错误报告和生产事件统计信息与上个月进行比较,这需要人工批准将产品发布发布。 我们还将评估开发人员和测试工程师如何利用他们的时间来查看这是否对我们所有应用程序都是有益的方法的差异。 如果操作不顺利,请重新启动手动批准步骤是一项三十秒的工作。

    Implementing an automated solution before you have a good manual one

    在拥有良好的手动解决方案之前实施自动化解决方案

    When do we do it?

    我们什么时候做?

    Even when automation really does have the potential to change our lives for the better, we cannot reap the benefits without understanding how and why it does so. One of the best ways to understand an automated solution is to know how to solve the problem manually first. Anyone who has ever made a cup of coffee or vacuumed a floor can understand how a machine would go about solving the same problem, and how to recognise when the machine messes up and we need to jump in. But so many facets of our lives are now beautifully tech-enhanced that it seems like a waste of time establishing manual processes before automating them. We’re so used to great solutions from machines, we want to jump straight to that endpoint in every situation.

    即使自动化确实确实有潜力使我们的生活变得更好,但如果不了解这样做的方式和原因,我们也无法获得收益。 理解自动化解决方案的最好方法之一是先知道如何手动解决问题。 曾经喝过咖啡或用吸尘器吸过地板的任何人都可以理解机器如何解决相同的问题,以及如何识别机器何时混乱,我们需要跳进去。但是,我们生活中的许多方面现在通过精美的技术增强功能,似乎在自动建立手动流程之前浪费时间。 我们已经习惯了使用机器提供出色的解决方案,因此在每种情况下我们都希望直接跳到该端点。

    Why shouldn’t we do it?

    我们为什么不应该这样做呢?

    When automation didn’t work as well at Tesla as Musk hoped, he was able to fall back on established car manufacturing processes that have been in place for a long time. When we automate before establishing how this problem might be solved by humans using older or no technology, we have no fallback plan if the automated solution doesn’t work. At best, a working solution will be delayed, and, at worst, the problems caused by the automated solution will make solving the problem manually harder than it had to be. Using established manual approaches first, and better understanding why they work in your particular context, is also likely to inform a more appropriate, human-assistive automated process. A comparable manual process is also an effective way of explaining to users what an automated solution is trying to achieve.

    当特斯拉的自动化工作不如马斯克所希望的那样时,他便能够依靠已存在很长时间的既定汽车制造Craft.io。 当我们在确定人类如何使用较旧的技术或不使用任何技术解决此问题之前实现自动化时,如果自动化解决方案不起作用,我们将没有备用计划。 充其量,一个有效的解决方案将被延迟,而在最坏的情况下,由自动化解决方案引起的问题将使手动解决问题的难度比必须解决的困难。 首先使用已建立的手动方法,并更好地了解它们在您的特定情况下起作用的原因,也可能会为更合适的,人为辅助的自动化过程提供信息。 可比的手动过程也是向用户解释自动化解决方案要实现的有效方法。

    What are the consequences?

    有什么后果?

    Throughout April and May 2020, the UK government spoke confidently about the key role a bespoke contact tracing app would have in their response to the Covid19 pandemic. However, after a disappointing attempt to launch the app to users in a small part of the UK, the government were forced to de-prioritise the app and quickly throw resources into the training and support of human contact tracers to follow up with associates of individuals who had tested positive. Without providing potential users with clear information about the app’s goals, abilities, or expectations, uptake was low, and confusion and misinformation high. A junior health minister was forced to admit “it is probably a mistake to launch an app before you have got the public used to the idea of tracing”.

    在整个2020年4月和2020年5月,英国政府充满信心地谈到了定制的联系人跟踪应用程序在应对Covid19大流行中所起的关键作用。 但是,在尝试向英国一小部分用户推出该应用程序后,令人失望的是,政府被迫取消该应用程序的优先级,并Swift将资源投入到人类接触追踪器的培训和支持中,以跟进个人的同事谁测试阳性。 如果没有为潜在用户提供有关应用程序的目标,功能或期望的清晰信息,则普及率很低,混乱和错误信息很高。 初级卫生部长被迫承认“ 在让公众习惯追踪之前,启动应用程序可能是一个错误 ”。

    Don’t say: Our developers aren’t taking the time to write helpful commit messages. Let’s implement all of the hooks to enforce a structure, and very long PR templates. That’ll learn ’em, probably.

    不要说:我们的开发人员不会花时间来编写有用的提交消息。 让我们实现所有挂钩以强制执行结构,以及非常长的PR模板 。 可能会学到它们。

    Do say: Our developers aren’t demonstrating an understanding of how to write helpful commit messages. Let’s provide clear guidance as to what makes a great commit message, lead by example, and get feedback from the developers as we discuss potential ways to improve the quality of our shared git log, including automated solutions.

    一定要说:我们的开发人员并没有表现出对如何编写有用的提交消息的理解。 让我们提供清晰的指导 ,以指导示例为例,提供最佳的提交信息,并在讨论提高自动化git日志质量的潜在方法时,从开发人员那里获取反馈。

    Conclusion

    结论

    Technologically enhanced and automated solutions continue to be applied effectively to a wide range of problems and situations, and this is a very good thing. However, allowing automation to be its own justification is a serious business risk. Any new approach, however exciting, must be exposed to a rigorous cost benefit analysis. We all must take an evidence-based approach to evaluating the tools and processes they use over the long term to ensure that the machines work for the humans, and not the other way around!

    经过技术增强和自动化的解决方案继续有效地应用于各种问题和情况,这是一件非常好的事情。 但是,让自动化成为自己的理由是严重的业务风险。 任何新方法,无论多么令人兴奋,都必须接受严格的成本效益分析。 我们所有人都必须采取基于证据的方法来评估它们长期使用的工具和过程,以确保机器对人类有效,而不是相反!

    翻译自: https://medium.com/dev-genius/classic-automation-mistakes-2bf74ad485ad

    vba 错误 自动化错误

    展开全文
  • On Error Resume Next '如果遇到错误,不管错误,继续往下执行,但如果嵌套了其他错误处理语句,这些错误处理语句还是会按照自己规则运行 语句xxxx On Error GoTo 0 ’结束错误捕捉 例子二: Sub 例子过程() ...

    自动关闭 Msgbox对话框:

    Private Declare Function MsgBoxEx Lib "user32" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As VbMsgBoxStyle, ByVal wlange As Long, ByVal dwTimeout As Long) As Long
    
     Private Sub 测试自动关闭对话框()
        MsgBoxEx 0, "显示内容:2秒后自动关闭", "标题", vbYesNo + vbInformation, 1, 2000
     End Su

    错误捕捉:

    例子一:

    On Error Resume Next  '如果遇到错误,不管错误,继续往下执行,但如果嵌套了其他错误处理语句,这些错误处理语句还是会按照自己规则运行
          语句xxxx
    On Error GoTo 0 ’结束错误捕捉

    例子二:

    Sub 例子过程()  
    
        On Error GoTo Err_Handle                 '之后语句出错则跳转至 Err_Handle 标签处
    
                 处理语句1                                        '若出错,则跳转到 Err_Handle
    
         On Error GoTo 0                             '跳出错误捕捉,之后语句若出错,自动弹出出错框  
                 处理语句2                                   '若出错则弹出错误,可调试或结束
    
           Exit Sub   '如果没有这个退出过程语句,会一直执行下去
    Err_Handle:
            MsgBox ("不存在该数字")
    
    End Sub
    

    转载于:https://blog.51cto.com/alun51cto/2392898

    展开全文
  • VBA错误语句处理

    千次阅读 2016-11-14 13:16:27
    执行阶段有时会有错误的情况发生,利用On Error语句来处理错误,启动一个错误的处理程序。语法如下: On Error Goto Line ‘当错误发生时,会立刻转移到line行去 On Error Resume Next ‘当错误发生时,会立刻...
  • VBA错误检测机制

    2015-01-05 09:56:09
    参考链接:http://blog.csdn.net/pfsx79/article/details/5414786 转载于:https://blog.51cto.com/acadia627/1599183
  • vba错误编号所对应的错误信息(备查) 可捕获的错误 可捕获的错误通常发生在应用程序运行时,但也有一些会发生在开发期间或编译时间。可使用 On Error 语句与 Err 对象来探测并回应可捕获的错误。1 – 1000 之间...
  • VBA里的编译错误,就是写在VBE里,还没运行就报错的那类错误 1.2 运行错误(和数据关系较大): 运行时才会出错的错误 比如一个语句运行时发现此操作会无法进行,卡住,或者返回值报错等等 这...
  • VBA 忽略错误

    千次阅读 2021-01-23 21:19:33
    VBA 忽略错误 在过程前 加一句 On Error Resume Next 出现错误时会跳过错误语句继续下一条代码,不过不建议使用,会使程序达不到预期效果 可以使用遇到错误时结束 on error goto XXX ………… XXX: exit ....
  • VBA错误处理(十八)

    2019-09-28 00:14:50
    在(VBScript/VBA)编程中有三种类型的错误: 语法错误 运行时错误 逻辑错误 语法错误 语法错误(也称为解析错误)发生在VBScript的解释时间。 例如,下面一行导致语法错误,因为它缺少一个右括号。 ...
  • VBA中的错误处理

    千次阅读 2017-11-21 16:22:00
    从理论上讲,VBA没有提供任何的错误处理机制,这种被用在微软Office产品中的以Visual Basic语言为基础的脚本语言根本就不要任何的错误处理,当程序出现错误或产生异常情况时,VBA会自动定位到出错的代码行,然后提示...
  • <p>VBA 代码可以运行但运行完提示运行错误‘5’,无效的过程或调用参数,代码段指向If rng.Value = "┏" And rng(n + 1, 1).Value = "┗" Then行,请大神看看是什么...
  • EXCEL vba 运行错误438

    2017-03-13 16:10:13
    运行错误 438,对象不支持该属类或方法,我用的EXCEL2013版,WIN7-64BIT 这是错误代码 : Sub BrowseToSite() Dim IE As New SHDocVw.InternetExplorer 'Set IE = New SHDocVw.InternetExplorer IE.Visible ...
  • VBA 出现400错误

    千次阅读 2018-08-01 11:39:04
    https://blog.csdn.net/xulianboblog/article/details/14230001
  • VBA-语法-错误处理

    2019-08-20 10:50:34
    On Error GoTo 如果自本行开始后面的代码执行出错,则跳至指定位置继续执行。...在Err对象中包含一个HelpFile属性 : "C:\PROGRA~1\COMMON~1\MICROS~1\VBA\VBA7\2052\VbLR6.chm" 这里有一些语言参考还是有点用的
  • VBA 400错误

    2016-11-04 11:18:00
    400错误,通常是Excel中的对象找不到时的报错。 示例1:“数据透视表1”是默认中文Excel中的pivottable的名字,被自己习惯性改为英文的"Pvt1",执行到这里的时候,找不到pivottable对象。按理应该报"Object ...
  • vb6、vbA返回错误行号的系统变量Erl

    千次阅读 2017-08-01 15:53:09
    导出表结构 ,我下载了 一位网友的程序 修改时 发现 老是 3720 错误,于是查询 解决方法,没想到 发现了 VB6 VBA 返回错误行号 的 系统变量Erl,在某些情况下 非常有用,当然下面的程序,是在没有发现Erl前写的,...
  • VBA Err错误处理 等

    2019-10-07 03:37:44
    1.Instr()函数 1. Instr用法举例如下:   Debug.Print InStr(1, "SFSA_UBS_ddd", "uBS", vbBinaryCompare) ' 返回 0 ,找不到 uBS; 因为 vbBinaryCompare 区分大小写 ... Debug.Print InStr(1, "SFS...
  • vba 错误处理机制

    2011-02-22 21:36:00
    Private Sub CommandButton1_Click()  On Error GoTo Err_Handle  Dim a As Integer  Dim b As ...a / b '除数为0会导致运行时错误  MsgBox c  End Sub<br /
  • 解决VBA运行时错误13 类型不匹配问题 先说解决方法:找到出错的语句以后给里面的参数改类型,使其互相兼容。 比如:给单元格Cells()外面套个马甲 Val() 比如:给数字外面套个马甲Int() 详细的排查过程后面会慢慢讲...
  • iFIX调度 VBA脚本发出声音报警,经过现场测试并一直用。我选择的是调度后台运行。
  • 跑了一个多月的程序运行时突然报错, 怎么都调不好, 换电脑之后就OK了… 要疯掉… 估计是电脑卸载了啥东西,或装了啥东西,中毒了??? 慢慢找吧[哭]
  • VBA 错误处理-过滤

    千次阅读 2011-12-12 17:36:35
    错误代码是 应用程序定义或对象定义错误  Range(Cells(2, 1), Cells(s1EndL, 11)).AutoFilter Field:=2, Criteria1:=strKeys 分析: 一般这种语法没错.问题出在空值,错误的值. 或者Range 是有值. 用中断...
  • 我发现Excel VBA的解决方法是“运行时错误40036应用程序定义的错误或对象错误”。 它不能解决原始问题,该问题在excel中存在。 我看到的一些响应显示了一个简单的程序,它无法选择屏幕或屏幕上的某个单元。 这是一条...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 9,284
精华内容 3,713
关键字:

vba错误