InfoPath 加载项帮助 - 保存活动表单模板的副本、在设计模式下显示自定义按钮、在表单解决方案中调用方法
我正在尝试构建一个 InfoPath 加载项,以允许模板编辑器(而不是最终用户)预览填充了示例数据的表单。
首先,介绍一下我们的环境背景。 我们有一个自定义流程,它连接到 MOSS,下载给定表单的适当数据源程序集,并调用它们将数据从数据库加载到表单中(例如信件模板中的收件人地址信息)。 当下载表单并传递参数(通过 URL)以进行数据检索时,将启动此过程。 我可以通过命令行将参数传递到本地保存的表单模板来近似这种行为。
有了这些知识,我开始构建一个 InfoPath 加载项,该加载项将执行以下操作:
- 在设计模式下显示自定义工具栏按钮,模板编辑器可以单击该按钮以使用示例数据填充表单(需要传递参数)。
- 单击该按钮时,将活动模板的副本保存到临时文件夹中,并使用 Shell() 命令将参数传递到表单。 然后,该表单的副本将在单独的 InfoPath 窗口中启动。
我一路上参考了各种在线教程和 Apress Pro InfoPath 2007 来获取指导,并且像这里之前的帖子一样,发现可用的信息非常有限。 我已经完成了一半,但遇到了一些问题:
- 我能够显示自定义工具栏按钮,但只能在预览模式下显示。 我需要该按钮在设计模式下显示。
- Application.ActiveWindow.XDocument.SaveAs() 方法似乎仅保存表单,而不是整个模板。 也许这是因为我处于预览模式而不是设计模式? 也许解决第一个问题也能解决这个问题。
- 为了避免上述两个问题,我研究了如何在表单模板解决方案中调用 FormEvents_Loading 处理程序。 这将允许我向它传递测试参数,而不必保存副本并通过命令行启动它。 我不知道该怎么做。
有什么想法或建议吗? 在此先感谢您的帮助!
I'm trying to build an InfoPath add-in to allow template editors (as opposed to end users) to preview the form with sample data populated.
First, a little background on our environment. We have a custom process that connects to MOSS, downloads the appropriate datasource assemblies for a given form, and invokes them to load data from the database into the form (such as recipient address information in a letter template). This process is launched when the form is downloaded and passed parameters (via the URL) for the data retrieval. I am able to approximate this behavior by passing parameters to a locally saved form template via the command line.
Armed with that knowledge, I set out to build an InfoPath add-in that would do the following:
- Display a custom toolbar button in Design mode that the template editor can click to populate the form with sample data (requires parameters to be passed).
- When the button is clicked, save a copy of the active template to a temp folder and use the Shell() command to pass parameters to the form. The copy of the form would then be launched in a separate InfoPath window.
I referred to various online tutorials and Apress' Pro InfoPath 2007 for guidance along the way, and like previous posts on here, discovered the information available to be very limited. I'm part way there, but ran into a few issues:
- I was able to get the custom toolbar button to show up, but only in Preview mode. I need the button to show up in Design mode.
- The Application.ActiveWindow.XDocument.SaveAs() method appears to save only the form, not the entire template. Perhaps this is because I am in Preview mode rather than Design mode? Maybe addressing the first issue will resolve this as well.
- In an effort to avoid the two issues above, I looked into how I might call the FormEvents_Loading handler in my form template solution. This would allow me to pass it the test parameters without having to resort to saving a copy and launching it via the command line. I could not figure out how to do this.
Any ideas or suggestions? Thanks in advance for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否了解表单选项 -> 预览选项卡? 您可以在其中设置预览模板时使用的表单。 听起来这就是您想要做的。 可能使用插件修改默认预览表单,然后用户只需单击预览即可查看示例数据。
Are you aware of the Form Options -> Preview tab? In there you can set a form to use when previewing the template. It sounds like this is what you are looking to do. Possibly use the addin to modify a default preview form and then the user simply clicks preview to see your sample data.