Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Is it possible to call and use MSWORD in command line mode?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MK - 20 Sep 2005 12:54 GMT
Hello all,

Actually I would like to use the "Compare and modify" function in Word and
Excel, but instead of opening the word application to complete the task, is
there anyone know how to do it in command line mode? like c:\..\MSWORD
c:\test1.doc c:\test2.doc "Compare and modify"
or I need to write a VB program to call the function in MS office?
Any comment, suggestion?
or any related document for reference?
Thanx so mush for your help

MK  
Helmut Weber - 20 Sep 2005 16:05 GMT
Hi MK,

this has often been discussed,
and I haven't seen a simple solution.

I'd try to start word with a macro,
like winword /mMycompare.

Put the names of the files to be compared
in a txt-file. Have the macro read the txt-file,
do the comparison and so forth.

>but instead of opening the word application to complete the task, is
>there anyone know how to do it in command line mode?

Word would be started anyway.

If You are somewhat familiar to VB,
it's as easy as that.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

MK - 21 Sep 2005 03:39 GMT
Hello Helmut Weber,

Thanx for yout reply, actually I would like to do a integration with the
office compare and merge function(include excel, word, powerpoint...) with my
vb application, so that the client only need to select the documents from my
vb program, and my vb program will do the jobs and launch the result for the
client.  But if it does not support command line with function call, do you
have any suggestion on how to automate the works?
like:
1) setup a templete for word with auto start macro
2) program the vb to copy the source file to the templete word file
3) use command line to launch the templet word
would it work this way?

Thanx

MK

> Hi MK,
>
[quoted text clipped - 15 lines]
> If You are somewhat familiar to VB,
> it's as easy as that.
Helmut Weber - 21 Sep 2005 08:44 GMT
Hi,
controlling Word from VB is much the same as controlling Word
form Excel or Controlling Excel from Word.
Can't say a word to merge in Excel or other Office-applications.

You need something like this here, tested from Excel,
having set a reference to the Word-Library!

Sub Test100()
Dim oWrd As Word.Application
Dim oDoc As Word.Document
Dim Fil1 As String
Dim Fil2 As String
Dim Fil3 As String
Set oWrd = New Word.Application
Fil1 = "c:\test\test1.doc"
Fil2 = "c:\test\test2.doc"
Fil3 = "c:\test\test3.doc"
Set oDoc = oWrd.Documents.Add(Fil1)
oDoc.Merge Fil2, mergetarget:=wdMergeTargetNew
oWrd.Visible = True
End Sub

What kind of tool (dialog, listbox, textbox) or anything you use,
to get the filenames, doesn't matter.

When testing this code, note, that a new Word-Object is created.
In case you get an error, Winword.exe might still be in the
process-list.
With every error therefore, You get an additional Word-Object.
You may either kill the word-objects via the task-manager.
or use an already running instance of Word (getobject).

Anyway, can't be explained all here
and there remains some work to do for you.

Helmut Weber MVP WordVBA
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.