Macro for restoring source from .bak files
Thread poster: ahmadwadan.com

ahmadwadan.com  Identity Verified
Kuwait
Local time: 02:04
English to Arabic
+ ...
May 7, 2007

Dear colleagues,

I have created macro for restoring source text from .bak files however I still need the code like that stop macro when it reaches end of file (EOF). The line I added is (Loop Until EOF) but it sounds wrong (unfunctional). Any idea what is the code could be. I added the whole macro below:


Sub autorestoresource()

Do

Application.Run MacroName:="TemplateProject.tw4winOpenGet.Main"
Application.Run MacroName:="TemplateProject.tw4winRestoreSource.Main"

Loop Until EOF(1)

End Sub


 

gianfranco  Identity Verified
Brazil
Local time: 20:04
Member (2001)
English to Italian
+ ...
I keep a copy of the working files before clean-up May 7, 2007

Dear Ahmad,

this is not a direct answer to your question, but if I understand correctly you intend to use this macro to recover the content of a document after performing a clean-up with Trados, in case the clean-up doesn't go well or similar emergencies.

If this is the case, I would say that it is probably much safer to keep, in a folder, a copy of the uncleaned file, untouched, and perform the clean-up in another folder, using a copy of the work file.
This way, the uncleaned version is always available and a recovery will not rely on the vagaries of a .bak file or a macro.

bye
Gianfranco





[Edited at 2007-05-07 15:54]


 

Olaf (X)
Local time: 01:04
English to German
EOF is only for text files May 7, 2007

Hi Ahmad,

As far as I know, a line such as:

Loop Until EOF(1)

requires a previous file open statement. E.g.

Open "C:\Output.txt" for Output as #1

Without it, you'll get an error message. Therefore your code cannot work. I'm not that familiar with the Word object model, but I guess you'll have to use a For Each or a With statement with the appropriate collection.

A quick & dirty version is:

Code:

Sub RestoreSource()

Dim parCount As Paragraph

For Each parCount In ActiveDocument.Paragraphs
Application.Run MacroName:="tw4winOpenGet.Main"
Application.Run MacroName:="tw4winRestoreSource.Main"
Next

End Sub



However, this only worked with parts of a unclean test document. I guess you'd have to test for errors generated by the Trados macro to make this work.

Hope this helps,
Olaf


 

ahmadwadan.com  Identity Verified
Kuwait
Local time: 02:04
English to Arabic
+ ...
TOPIC STARTER
It works May 7, 2007

Olaf wrote:

Code:

Sub RestoreSource()

Dim parCount As Paragraph

For Each parCount In ActiveDocument.Paragraphs
Application.Run MacroName:="tw4winOpenGet.Main"
Application.Run MacroName:="tw4winRestoreSource.Main"
Next

End Sub





Hi Olaf,

Thank you so much. The code you provided works excellently.

May Allah bless you


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Macro for restoring source from .bak files

Advanced search







SDL Trados Studio 2019 Freelance
The leading translation software used by over 250,000 translators.

SDL Trados Studio 2019 has evolved to bring translators a brand new experience. Designed with user experience at its core, Studio 2019 transforms how new users get up and running, helps experienced users make the most of the powerful features, ensures new

More info »
TM-Town
Manage your TMs and Terms ... and boost your translation business

Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search