Jump to content

Export text and import it back


Ethen
 Share

Recommended Posts

Hi all,

 

i wish if i can find some can help me about this, i found those two attached scripts  to extract text from Microsoft Publisher to a *.txt file to be translated then import it back again.

 

it works by pressing on shortcut (`) while selecting the text inside the application then it will extract the text to outside *.txt file and replace it inside the file with a text box number to be imported back after translation.

 

the problem is when it exports text to a *.txt file it loses the format (bold/underline/italic...etc) so i wan't to modify this script to export it to a *.docx file with the same format without losing it to be imported back again with the same format.

 

i hope if someone can help it would be highly appreciated.

 

Thanks in advance

 

Cheers

 

Ethen 

 

Extract.au3

paste.au3

How it works.txt

Link to comment
Share on other sites

Once you save data as text it will always lose its formatting, why not save the document as .rtf for example:

Local Const $pbFileRTF = 6

Local $sPubDoc = "C:\My Documents\Publication.pub", $sPubDocSave = StringTrimRight($sPubDoc, 4) & ".rtf"

Local $oPub = ObjCreate("publisher.application")
$oPub.DisplayAlerts = False
Local $oPubDoc = $oPub.Open($sPubDoc)
$oPubDoc.SaveAs($sPubDocSave, $pbFileRTF) ;~ See https://docs.microsoft.com/en-us/office/vba/api/Publisher.PbFileFormat
$oPubDoc.Close
$oPub.Quit

 

Link to comment
Share on other sites

Hi Subz,

 

Thanks a lot brother for your reply, i know that text will always lose formatting so that's why i'm asking to export it to another format.

 

but the most important note is to export it and leave an ID number (text box number) replaced with the text, to be able to import the text back again.

so i need to modify both two scripts to generate and import back formatted text with no issues.

 

did you check the two scripts attached below to figure what i mean?

Extract.au3

paste.au3

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...