自定义客户端应用程序 - 需要能够控制文档的保存位置

发布于 2024-11-29 05:10:02 字数 1686 浏览 0 评论 0原文

好吧,所以。我需要一些指导。我对这篇文章的长度表示歉意,但我需要提供一些细节:

我有人对我感兴趣,可以为他们做一个小项目。一般来说,该应用程序是一个相当简单的员工记录保存/文档应用程序,但它大量使用模板化的 Word 和 Lotus 文档。这个想法是你选择员工“事件”,例如表彰、晋升、纪律等,它会加载适当的模板文档,你从那里填写它,稍后你可以选择一名员工,查看所有“事件”, ”并查看与每个文档相关的各个文档。

因此,应用程序必须知道用户完成后 .docs 的保存位置。

客户端实际上拥有此应用程序的 v1(它不会对文件或任何内容进行任何管理,只是启动Word/Lotus 以及您想要在新实例中查看的文档,大概是通过 system() 调用。)我们还没有进入详细的需求阶段,但客户和我同意,为此真的< /em> 工作,某种控制用户将 .doc 保存到的位置至关重要,因为否则应用程序会向他们提供模板文档的新副本,他们会在其他地方“另存为”,并且应用程序会指向空白复制它提供给他们的。

显然,我想不出一种方法可以通过启动一个新的 Word 实例来以任何方式实现“另存为”限制/控制。当您选择一个时,客户有一个想法,即在应用程序中嵌入带有模板文档的 Word/Lotus 实例,但我对此没有什么保留:

  • 我已经在网上进行了挖掘,并且阅读了我使用的任何版本的 Word从中借用 MSWORD.OLB 是否是最终用户需要的?
  • 我尝试从 此处 执行嵌入 Word 文档的 MSDN 示例,但正如我'我们已经习惯了,MSDN 示例甚至无法编译。
  • 即使我能弄清楚如何将 .doc 文件嵌入到他们的应用程序中,我也不知道我可以控制“另存为...”的使用,
  • 所有这些仍然没有触及 Lotus(!)

所以...本能地,我觉得嵌入式 Word/Lotus 的工作量最终会超过其价值。

所以我正在酝酿一些其他的想法。

  1. 一种是考虑使用 Office XML(如果有 Lotus 等效工具),并分别获取用户的“输入”并每次动态生成文档。我对这个想法并不是特别兴奋,但我认为它可以起作用,只要我只是使用旧功能来尝试保持向后兼容。
  2. 单独获取用户的“输入”并生成 HTML 文档。嗯。有效,非常跨平台并且易于解析和理解,但如果您希望能够通过电子邮件将其发送给某人(谁通过电子邮件发送 .html?有效,是的,非常非常规,这对于普通用户来说会抛弃他们),那么就不好了如果您需要将其通过电子邮件发送给某人进行修改,情况会更糟……
  3. 也许是某种可编辑的 PDF?我知道那里有 PDF 库,而且我对它研究得越多,这听起来就越像是最好的选择,尽管我没有对 PDF 做过太多工作,而且我不知道如何做它们易于嵌入/创建它们时有哪些选项。我知道他们可能会被储蓄禁用,我以前也曾因我该死的州税而遭受过这种情况。

我在这里需要一些意见。这是 TLDR 问题:

  1. 如果用户可以在任何地方“另存为”文档,然后应用程序会指向一个空白文档,那么为每个 .doc 启动一个新的 Word 实例是否像我感觉的那么糟糕?
  2. 尝试支持嵌入式 Word 是否像我感觉的那样是一个大麻烦/比其价值更多的工作/可能会导致支持多个版本的 Word 出现问题? (向前兼容性以及当前发布的版本?)
  3. 对 PDF 计划有什么想法?
  4. 还有其他好主意吗?

Okay SO. I need some guidance. I apologize for the length of this post, but I need to provide some details:

I've got someone who is interested in me to do a small project for them. The application in general is a fairly straightforward employee record keeping / documentation app, but it makes pretty heavy use templated Word and Lotus documents. The idea is you select the employee “event” such as commendation, promotion, discipline, etc., and it loads the appropriate template doc and you fill it in from there, and later you can select an employee, view all the “events,” and view the individual documents associated with each one.

Thus, the app must know where the .docs are saved when the user is done.

The client actually has a v1 of this app (it doesn’t do any management of the files or anything, just launches Word/Lotus with the document you wanted to view in a new instance, presumably via a system() call.) We’ve not gotten into a detailed requirements phase, but the client and I agree that for this to really work, some kind of control over where the user saves the .doc’s to is going to be critical , because otherwise the app provides them with the new copy of the template doc, they "Save as" somewhere else, and the app is pointing to the blank copy it provided them with.

Obviously, I can’t think of a way to achieve “Save as” restriction/control in any way via just launching a new instance of Word. The client has the idea of an embedded Word/Lotus instance in the app with the template doc when you choose one, but I’ve few reservations with that:

  • I’ve dug around online and I’ve read that whichever version of Word I borrow MSWORD.OLB from will be the one the end user would require?
  • I’ve tried to do the MSDN example of embedding a Word doc from here, but as I’ve come to get used to, the MSDN example doesn’t even compile.
  • Even if I CAN figure out how to embed a .doc file into their application, I don’t know that I could control the use of “Save as…”
  • All of this STILL hasn’t touched on Lotus (!)

So… instinctively, I feel the embedded Word/Lotus thing has to be more work than it’s worth in the end.

So I’ve had a few other ideas brewing around.

  1. One is looking into using Office XML (and if there’s a lotus equivalent), and get the user’s “inputs” separately and generate the document on the fly each time. I’m not particularly thrilled with that idea, but I think it COULD work, provided I just use old features to try and stay far backwards compatible.
  2. Get user’s “inputs” separately and generate a document in HTML. Meh. Works, very cross platform and easily parsed and understood, but not good if you want to be able to email it to someone (who emails a .html? Works, yes, very unconventional which to the average user will throw them off) and even worse if you need to email it to someone for revisions…
  3. Perhaps some kind of editable PDF? I know there are PDF libraries out there, and the more I stew on it, the more this sounds like the best option, though I’ve not done much work with PDFs and I don’t know how easily embeddable they are / what options one has when creating them. I know they can be save-disabled, I’ve had that with my bloody state taxes before.

I need some input here. Here’s the TLDR questions:

  1. Is launching a new instance of Word for each .doc as bad as I feel, given user can “Save as” document wherever and then application is left pointing to a blank document?
  2. Is trying to support embedded Word as big of a trouble as I feel like it is / more work than it’s worth / likely to cause problems with supporting multiple versions of Word? (Forward compatibility as well as currently released versions?)
  3. What are thoughts on the PDF plan?
  4. Any other good ideas?

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

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

发布评论

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

评论(1

日暮斜阳 2024-12-06 05:10:02

Word 确实允许通过其对象模型对某些“保存”和“另存为”控件进行编程。任何用 VBA 编码并放入 Word 模板中的子例程都将被复制到从该模板生成的所有文档中。此外,大多数菜单和功能区命令都可以通过创建一个包含以拦截命令命名的子例程的模块来拦截。因此,例如,如果一个模块包含一个名为 FileSaveAs() 的子函数,则该子函数中的任何代码都将被执行,而不是标准的 File|Save As 命令。最后,此代码将取代通过按键、工具栏、菜单或功能区执行的“另存为”命令。

每当执行“保存”或“另存为”命令时,下面的代码将启动一个对话框到预定路径:

Sub FileSave()
ControlSaveLocation
End Sub

Sub FileSaveAs()
ControlSaveLocation
End Sub

Sub ControlSaveLocation()
Dim Directory As String
Directory = "C:\Documents\"
With Application.Dialogs(wdDialogFileSaveAs)
    .Name = Directory
    .Show
End With
End Sub

希望这会有所帮助。

Word does allow for programming some "Save" and "Save As" control via its object model. Any subroutines coded in VBA and placed into your Word template will be copied into all documents generated from that template. Additionally, most menu and Ribbon commands can be intercepted by creating a module containing subroutines named for the intercepted commands. So, for example, if a module contains a sub named FileSaveAs(), any code in that sub will be executed instead of the standard File|Save As command. Lastly, this code will replace Save As commands executed via keystroke, toolbar, menu, or Ribbon.

The code below will launch a dialog box to a predetermined path whenever a "Save" or "Save As" command is executed:

Sub FileSave()
ControlSaveLocation
End Sub

Sub FileSaveAs()
ControlSaveLocation
End Sub

Sub ControlSaveLocation()
Dim Directory As String
Directory = "C:\Documents\"
With Application.Dialogs(wdDialogFileSaveAs)
    .Name = Directory
    .Show
End With
End Sub

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文