Open all word docs in folder & run macro (character map)

January 11, 2013 at 02:23:57
Specs: Windows 7 Ultimate
I read the thread below and this looks like almost the solution I need.

I have to run a character map on multiple files and need a way to run a script that asks me for the folder to process.

http://www.computing.net/answers/pr...

Thanks


See More: Open all word docs in folder & run macro (character map)

Report •


#1
Report •

#2
January 11, 2013 at 07:09:49
Character map in this sense is part of the translation process of Framemaker files.

Files are saved into the Framemaker mif format (similar to .doc > .rtf).

These are then converted to .rtf files through translation software.

When languages such as Czech, Polish, Serbian are used, some characters do not convert properly when importing back to Framemaker.

These characters are substituted in word before the conversion, e.g.
á>£E
Á>£L
é>£F
É>£K
č>$A
Č>$B
ď>$C
Ď>$D

I have found one solution to this now (below), but any suggestions are welcome.

Thanks

Nick

This vb script works from inside word, asks for a folder to process, then runs the script "CHmapCZ_tested" on each file in the folder. The "CHmapCZ_tested" script find/replaces the characters as above, so that the conversion can be reversed in Framemaker.

-----------------------------------------------------------------
Sub aRUNcmCZ()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = dir(strFolder & "\*.rtf", vbNormal)
While strFile <> ""
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=True)
With wdDoc
Application.Run MacroName:="CHmapCZ_tested"
End With
wdDoc.Close SaveChanges:=True
strFile = dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub

Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function


Report •

#3
January 11, 2013 at 11:59:52
Ah. Well then if you have a working solution, what is it you're looking for? (Other than decent UTF support from your tools?)

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
January 16, 2013 at 06:03:28
I need to fine tune this with the ability to choose the macro depending on which language I am character mapping.

Is there a way to amend the line
Application.Run MacroName:="CHmapCZ_tested"
to display the macros available and replace "CHmapCZ_tested" with whatever I pick from the list?

Should have listened at school!


Report •

#5
January 16, 2013 at 13:00:25
One way would be to use commandline arguments, but that doesn't give you a menu-selection. A menu can be made in either a batch-script or the vbscript by displaying all the files with the macroname extension (vbs?) or some subset based on your own naming convention. Then just use set /p (batch) or wscript.stdin.readline (vbscript) to obtain the input. sample vbscript snippet:
'===== begin vbscript
set fso=createobject("scripting.filesystemobject")
set folder=fso.getfolder(".")
for each file in folder.files
if lcase(fso.getextensionname(file))=".vbs" then wscript.echo file.name
next
wscript.stdout.write ("selection from above: ")
map=wscript.stdin.readline

Report •

#6
January 21, 2013 at 05:51:11
This needs more love than what I have time for, and it's VBA (not VBScript), so off to the Office forum it goes.

How To Ask Questions The Smart Way


Report •

Ask Question