VBA 状态栏

发布于 2024-07-11 20:37:32 字数 949 浏览 6 评论 0原文

我正在为 80 名左右的用户开发 Word VBA 宏应用程序。 该办公室的人员流动率很高,因此培训受到影响,因此该项目的自我要求之一是全面、友好的文档。 然而,为了补充这一点,并避免新手在想要尝试新东西时不得不打开 100 页的文档,我希望每个用户窗体(有五个)上都有一个提供上下文帮助的状态栏。 我觉得工具提示很烦人。

我没有太多经验,所以我想

本质上,我有一个包含每个状态字符串的文件。 (当前这是一个文本文件,但我想知道是否应该使用电子表格或 csv 以便将来其他人员进行编辑。)每个控件都有一个 MouseMove 事件,该事件引用一个函数: getStatus(cID) ,该函数打开文件,抓取该行并将其显示在状态标签中。 它还从文件中的同一行获取一些参数,例如标签是否可单击(链接到帮助文件中的页面)以及标签应该是什么颜色。

所以有几个问题:

如果用户窗体不断引用文件,应用程序会变慢吗? 这对我来说感觉很好,但我已经呆得太久了,而且我是唯一访问该文件的用户。 将有 80 个不断访问它。

在控件上移动鼠标是最好的方法吗? 我应该使用坐标吗?

最重要的是(就我必须做尽可能少的工作而言)是否有某种方法可以做到这一点,以便我不必在每个控件上都有 MouseMove 事件? 我有几百个左右的控件,每个控件都有自己的标识符(好吧,还没有,但如果这是唯一的方法,他们会的)。 也许当加载表单时,我可以加载所有可能的状态行,以便每当将鼠标悬停在控件上时它们都已准备好。 但是,也许加载时间可以忽略不计?

感谢任何想法或想法 - 特别是如果 VBA 已经拥有一整套功能来完成此任务,而我只是想重新发明轮子。 我无法使用应用程序状态栏,因为用户很少看到应用程序本身。

谢谢!

编辑:

它用于数据输入、点击和一些文档生成。

这是一个受控环境,因此宏观安全问题对我来说并不是一个大问题 - 如果出现问题,那是其他人的错误或问题:)

I am working on a Word VBA macro app for 80 or so users. The office has high staff turnover, so training suffers, and so one of the self imposed requirements for this project is comprehensive, friendly documentation. However, to supplement this, and to save newbies having to open up a 100 page document when they want to try something new, I want a status bar on every userform (there are five) that provides contextual help. I find tooltips annoying.

I don't have a lot of experience, so I was wanting to

Essentially, I have a file containing every status string. (This is currently a text file, but I was wondering if I should use a spreadsheet or csv for ease of editing by other staff in future.) Every control has a MouseMove event which refers to a function: getStatus(cID) that opens the file, grabs the line and displays it in the status label. It also grabs a few parameters from the same line in the file, such as whether the label is clickable (to link to a page in the help file), and what colour the label should be.

So a few questions really:

Will the application be slow if a userform is constantly referring to a file? It feels fine to me, but I've been in it far too long, and I'm the only user accessing that file. There will be 80 constantly accessing it.

Is MouseMove over a control the best way? Should I instead use co-ordinates?

Most importantly (in terms of me having to do as little work as possible) is there some way to do this so that I do not have to have a MouseMove event on every single control? I have a good few hundred or so controls, each with their own identifier (well, not yet, but they will if this is the only way to do it). Maybe when the form loads I could load ALL the possible status lines so they're ready for whenever the control is moused over. But then, maybe the loading time is negligible?

Appreciate any ideas or thoughts - especially if VBA already has a whole range of functions to do this already and I'm just trying to reinvent the wheel. I can't use the application status bar, because the user rarely sees the application itself.

Thanks!

EDIT:

It is for both data entry, clicking around and a bit of document generation.

It is a controlled environment so macro security issues aren't a big concern for me - and if something goes wrong it's someone else's fault or problem :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

極樂鬼 2024-07-18 20:37:32

这是数据输入应用程序还是他们只是点击一些东西? 因为焦点字段通常与鼠标悬停的项目不同,这可能会导致很多混乱。

不断地从文件中读取是对时间和资源的巨大浪费 - 最好在加载表单时将它们加载到数组或集合中一次。

在 MouseMouse 事件上比坐标更好,因为您可以放心地移动物体。 这是很多代码,但如果您有控件名称列表,您应该能够生成其中的大部分,因为代码应该是相同的。

IE

Sub Control_MouseMove()
  DisplayStatus(Control)
End sub

Is this data entry app or do they just click stuff? Because often the field with focus is different to the item the mouse is hovering over, this can cause a lot of confusion.

Constantly reading from a file is a huge waste of time and resources - it is much better to load them only once into an array or collection when the form is loaded.

On MouseMouse event is better than coordinates because you can move things around without worrying. It's a lot of code but you should be able to generate most of that if you have a list of control names because the code should be identical.

ie

Sub Control_MouseMove()
  DisplayStatus(Control)
End sub
沫尐诺 2024-07-18 20:37:32

我会考虑控件的 StatusText 属性和 ControlTipText 属性来提供此类帮助。

状态文本
此示例为名为“Age”的表单字段设置状态栏帮助文本。

With ActiveDocument.FormFields("Age")
    .OwnStatus = True
    .StatusText = "Type your current age."
End With

控制提示文本
这可以从控件的属性表中分配。

Private Sub UserForm_Initialize()
    MultiPage1.Page1.ControlTipText = "Here in page 1"
    MultiPage1.Page2.ControlTipText = "Now in page 2"

    CommandButton1.ControlTipText = "And now here's"
    CommandButton2.ControlTipText = "a tip from"
    CommandButton3.ControlTipText = "your controls!"
End Sub

I would consider the StatusText property and ControlTipText property of controls for this kind of help.

StatusText
This example sets the status bar help text for the form field named "Age."

With ActiveDocument.FormFields("Age")
    .OwnStatus = True
    .StatusText = "Type your current age."
End With

ControlTipText
This can be assigned from the property sheet for the control.

Private Sub UserForm_Initialize()
    MultiPage1.Page1.ControlTipText = "Here in page 1"
    MultiPage1.Page2.ControlTipText = "Now in page 2"

    CommandButton1.ControlTipText = "And now here's"
    CommandButton2.ControlTipText = "a tip from"
    CommandButton3.ControlTipText = "your controls!"
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文