如何使用/m“宏参数"打开Word文档从Java/或命令行,无需指定winword.exe路径 [英] How to open word document with /m "Macro argument" from java/or command-line without to specifi winword.exe path

查看:325
本文介绍了如何使用/m“宏参数"打开Word文档从Java/或命令行,无需指定winword.exe路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做下一件事:

String[] cmd  = {"cmd","/c","c:\\Program Files (x86)\\Microsoft Office\\Office12\\WINWORD.exe","/mOpenPage","c:\\Navodilo.doc"};            
Process proc = Runtime.getRuntime().exec(cmd);

但是,无需指定winword.exe路径,而是使用宏打开文档...

But, without to specify the winword.exe path but open the document with the macro...

我了解到存在自动打开宏,是否可以为自动打开宏指定输入参数?

I read that there exist Auto Open macro, is it possible to specify input arguments for Auto Open macro?

已解决:

String[] cmd  = {"cmd","/c","start","WINWORD.exe","/mOpenPage","c:\\Navodilo_za_uporabo_spletnega_servisa_wsEdp.doc"};
Process proc = Runtime.getRuntime().exec(cmd);

它运行默认的winword.exe并使用指定的宏打开Word文档

It runs default winword.exe and open word document with specified Macro

推荐答案

我为您提供了两个选择:

I see two options for you:

  1. 从注册表中读取winword.exe的路径.它存储在

  1. Read the path to winword.exe from the Registry. It is stored under

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Word\InstallRoot

其中12.0必须是正确的Office版本(Office 2007 = 12,Office 2003 = 11等).

where 12.0 needs to be the correct Office version (Office 2007 = 12, Office 2003 = 11 etc).

除了使用/m开关,您还可以使用自动宏.此处描述了如何完成此操作:

Instead of using the /m switch you could also use an auto macro. How this is done is described here:

http://support.microsoft.com/kb/211659

这篇关于如何使用/m“宏参数"打开Word文档从Java/或命令行,无需指定winword.exe路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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