VBA for Word 2013并不总是展示识别功能 [英] VBA for Word 2013 not always exhibiting identifcal functionality

查看:113
本文介绍了VBA for Word 2013并不总是展示识别功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那里,

我有几百个用户使用Word 2013的VBA字宏。

I have several hundred users using a VBA word macro for Word 2013.

作为VBA的一部分代码逻辑读取URL文档并将这些URL放入数组中。

as part of the VBA code the logic reads a document of URLs and places those URLs into an array.

而bContinue

    

   如果Selection.Type = wdSelectionIP和Selection.End = ActiveDocument.Content.End - 1则为
        b继续= iFalse

   结束如果

While bContinue
   
    If Selection.Type = wdSelectionIP And Selection.End = ActiveDocument.Content.End - 1 Then
        bContinue = iFalse
    End If

    Selection.EndKey Unit:= wdLine,Extend:= wdMove

    Selection.HomeKey Unit:= wdLine,Extend:= wdExtend

    sLineString $ = RTrim $(Selection.Text)

    Selection.EndKey Unit:=wdLine, Extend:=wdMove
    Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
    sLineString$ = RTrim$(Selection.Text)

    "  如果该行包含网址

   如果((InStr(UCase(sLineString $),UCase(sURL_LineChar $))> 0)或(InStr(UCase(sLineString $),UCase("C:\"))> 0))那么

       

        "  添加到阵列列表中$
        sURL __ $(iNumOfFiles)= sLineString $

    '   If the line contains a url
    If ((InStr(UCase(sLineString$), UCase(sURL_LineChar$)) > 0) Or (InStr(UCase(sLineString$), UCase("C:\")) > 0)) Then
       
        '   Add to list of arrays
        sURL__$(iNumOfFiles) = sLineString$

        "  增量数组

        iNumOfFiles = iNumOfFiles + 1

   结束如果

       

    "  转到下一行

    Selection.MoveDown Unit:= wdLine,Count:= 1,Extend:= wdMove

        '   Increment array
        iNumOfFiles = iNumOfFiles + 1
    End If
       
    '   Move to next line
    Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdMove

Wend

问题在于数百名用户的工作原理所有的时间,但我们总是有2或3个用户,它不起作用。虽然并不保证所有硬件都是相同的,但所有工作站软件的安装都是相同的,并且应该是相同的。

the issue is that for hundreds of users this works all the time and yet we always have 2 or 3 users where it does not work. while all hardware is not guaranteed to be the same, all workstation software installs are imaged and should be the same.

我亲眼看到了sLineString $的部分内容隔断。有一次我能够在一台无法正常工作的机器上体验这一点我曾经踩过宏来观察行为。看到问题后,我在逻辑中提前设置
断点。然后行为奇迹般地纠正了自己!我们无法让机器再次失败!遗憾的是,这不是问题的解决方案。

i've seen it with my own eyes that part of the sLineString$ gets cut off. the one time I was able to experience this myself on a machine that wasn't working I had been stepping through the macro to observe the behavior. After seeing the problem I then set break points earlier in the logic. then the behavior miraculously corrected itself! and we could not get the machine to fail again! unfortunately, this is not a solution to the problem.

我们发现在某些情况下,带有操作系统和软件的工作站的重新映像可以解决问题,但这是一个相当昂贵的过程。

we have found that in some cases a re-image of the workstation with operating system and software rectifies the issue but is a rather expensive process.

我还有其他用户有这样的问题,这个问题在其他工作站上是不可重复的。

I additionally have other users who have separate issues like this one that is not repeatable on other workstations.

对我们可以做什么的任何见解非常感谢稳定执行环境或发现逻辑中的解决方法。

any insight into what we can do to stabilize the execution environment or discover a work around in the logic is greatly appreciated.

推荐答案

如果重新启动PC,它是否有效? Word似乎存储了错误条件,并且凭借世界上最好的意愿,您可以保证,如果某些事情可以被搞砸,用户将找到一种方法来做到这一点。重新启动将清除错误。另请参阅
http://www.gmayor.com/what_to_do_when_word_crashes.htm 关于孤立文件。
Does it work if you reboot the PC? Word seems to store up error conditions and with the best will in the world you can guarantee that if something can be screwed up a user will find a way to do that. Rebooting will clear the errors. See also http://www.gmayor.com/what_to_do_when_word_crashes.htm with regard to orphaned files.


这篇关于VBA for Word 2013并不总是展示识别功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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