VBA - 将焦点设置为内容控件 [英] VBA - Setting focus to a content control

查看:205
本文介绍了VBA - 将焦点设置为内容控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Word VBA乐趣的新手。我有一个用户键的表单,其中依次用用户输入的值填充Word文档。提交后,我希望重点放在文档中的某个点上。我知道对于标准文本框,这可以通过使用SetFocus方法来实现。



这似乎不适用于内容控件。我想避免使用书签,因为我相信人们正在更多地转向内容控制。我想我有几个问题:



1.我应该使用内容控件来实现这一目标吗?如果不是我应该如何/应该使用什么?



2.如果内容控件是这些问题的前进方法,我该如何将焦点设置为内容控件?



谢谢!

Hi, I'm new to the pleasures of Word VBA. I have a form that the user keys in which in turn populates the Word document with the user entered values. Once submitted, I would like the focus to be at a certain point in the document. I know that for standard textboxes this can be achieved by using the SetFocus method.

This doesn't seem to be available for content controls though. I would like to avoid using bookmarks as I believe people are moving more towards content controls. I suppose I have a couple of questions:

1. Should I use content controls to accomplish this? If not how/what should I use?

2. If content controls is the way forward for these kinds of problems, how can I set the focus to the content control?

Thanks!

推荐答案

设置书签,说MyBookmark并使用以下语句:你的VBA代码:

Set a bookmark, say "MyBookmark" and use the following statement in your VBA code:
Selection.GoTo What:=wdGoToBookmark, Name:="MyBookmark"


谢谢,太棒了!



书签很好。
Thanks, that's great!

Bookmarks is good.


这篇关于VBA - 将焦点设置为内容控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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