Hi Guys,
Using Applescript, I am trying to run a VB macro in all MS Word Files (doc, docx) of Selected folder and all subfolders and to save as all the file as Plaint Text format.
But What I get the result is Original file is Saved as Text format. And the Macro is runned on all original Documents and stay opening.
Below Script for your reference.
set folderToProcess to (choose folder with prompt "Choose Folder::")
tell application "Microsoft Word"
close every document saving no
end tell
tell application "Finder"
activate
set fileExt to {".doc", ".docx"}
set theTopFolder to (folderToProcess as alias)
repeat with EachFile in (get every file of folder (folderToProcess as alias))
set FileName to EachFile as text
try
copy name of EachFile as string to FileName
repeat with ext in fileExt
if FileName ends with ext then
set result to (open EachFile)
tell application "Microsoft Word"
--I think help needed in below 2 lines
run VB macro macro name "Normal.NewMacros.MyMacro"
do shell script "textutil -convert txt " & quoted form of POSIX path of (EachFile as text)
end tell
--msg(result)
end if
end repeat
end try
end repeat
--display dialog (theTopFolder as text)
repeat with EachSubDir in (get every folder of folder theTopFolder)
try
--display dialog (EachSubDir as text)
repeat with EachFile in (get every file of folder (EachSubDir as alias))
try
copy name of EachFile as string to FileName
--display dialog FileName
--move Eachfile to theTopFolder
repeat with ext in fileExt
if FileName ends with ext then
--display dialog FileName
set result to (open EachFile)
tell application "Microsoft Word"
--I think help needed in below 2 lines
run VB macro macro name "Normal.NewMacros.MyMacro"
do shell script "textutil -convert txt " & quoted form of POSIX path of (EachFile as text)
end tell
--delete Eachfile
--msg(result)
end if
end repeat
end try
end repeat
--delete folder (EachSubDir as alias)
end try
end repeat
end tell
Any Help would be appreciated.
Thanks in advance
John