Computing.Net > Forums > Office Software > Batch File For Word

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File For Word

Reply to Message Icon

Name: John
Date: December 11, 2003 at 11:32:39 Pacific
OS: Win XP Home
CPU/Ram: 2.8GH 512MB
Comment:

Basically, I have a folder with about 20 Word docs in it. I want a BAT that will open the first file in Word, execute a macro that I have written--which includes saving the file and closing Word, then move to the next file.

I've gotten this far:

for %%x in (*.doc) do start c:\progra~1\micros~2\office\winword.exe "%%x" /mmacro1

The problem with this is that it opens all 20 of the documents simultaneously, and won't execute the macro on any of them. Plus, it screws up the normal.dot template because multiple instances of Word are open.

Any ideas???



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: December 11, 2003 at 13:08:22 Pacific
Reply:

About executing serially add the /Wait switch to the Start command

For %%x in (*.doc) Do Start /Wait C:\Progra~1\Micros~2\Office\WinWord.exe "%%x" /mmacro1

Regarding the execution of the macro that is beyond my know-how.


0

Response Number 2
Name: John
Date: December 11, 2003 at 14:28:31 Pacific
Reply:

Perfect!! I knew I was missing something. The /Wait switch was it. The Word macro is my know-how, so I'm good to go. Thanks!

One follow-up question, I have a folder with about 50 different Windows shortcuts. They are all named "Shortcut to <filename>". Is there a way to batch rename them all so that "Shortcut to" is eliminated?


0

Response Number 3
Name: IVO
Date: December 12, 2003 at 02:15:39 Pacific
Reply:

The script below performs what you need

@Echo Off
:: SHREN.BAT Syntax: ShRen FolderName

For /F "tokens=1,2,*" %%A in ('Dir /B "%*\Shortcut*.*"') Do (
Echo Ren "%*\%%A %%B %%C" "%%C")

[the For /F statement is contained in one line ending with "DO (" CR/LF]

To run Type ShRen FolderName where FolderName is the pathname-name of desidered folder; there are no restrictions on the name, i.e. blanks and long file names allowed (e.g. ShRen C:\My Folder\My Documents), but, as you see, omit surrounding quotes anyway.
The script has to be activated removing the Echo in front of Ren: do it only when sure it works as expected.
If anything goes wrong, post again.
Good work


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Batch File For Word

win 95 batch file parsing www.computing.net/answers/office/win-95-batch-file-parsing/9637.html

.dwg file in Word www.computing.net/answers/office/dwg-file-in-word/800.html

problem opening word 2003 www.computing.net/answers/office/problem-opening-word-2003/2812.html