• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

A challenging question for experts

I have converted a pdf file containing japanese fonts to a text file. so when i open the text file it shows me junk in place of japanese character.

Now when i change the extension from txt to doc and open the file it asks me for encoding and i select UTF-8 and the page gets successfully opened.

now where i need your help is to automate this process of changing the extension name from txt to doc from my VB application and selecting UTF-8 encoding and reading the doc file.

Regards
A.Pandey
0
Amitabh
Asked:
Amitabh
  • 2
  • 2
  • 2
  • +1
1 Solution
 
aikimarkCommented:
The first part is relatively simple:
Name oldpathname.txt As newpathname.doc

========================================
The second part requires you to create a word OLE automation object and then invoke the object's OPEN method, specifying the UTF-8 encoding as one of the parameters of the Open method.
0
 
Chandramouli kArchitectCommented:
** include project-references-micorsoftword9.0 object library.

** change the folder path in Open Statement


Dim docPolicy As Word.Document
Private Sub Command1_Click()
Set docPolicy = Documents.Open("c:\KCM\TEST.TXT")
With docPolicy
   .SaveAs FileName:="C:\kcm\test.doc"
   .Close
End With
Set docPolicy = Nothing
End Sub

ALL THE BEST
0
 
AmitabhAuthor Commented:
Its giving me error here
 Set docPolicy = Documents.Open("c:\xpdf\app.txt")

error is :
"Active X component can't create object"

i have checked for the path. also i know, i have to give UTF-8 encoding so how will i give it. open function provides encoding as optional argument.

Regards
A.Pandey

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Chandramouli kArchitectCommented:
ya, i too got the same error, not the first time, but from second time onwards...

try this
**include project-references-micorsoftword9.0 object library

Dim docPolicy
Private Sub Command1_Click()
Set docPolicy = CreateObject("Word.Document")
Set docPolicy = Documents.Open("c:\KCM\TEST.TXT")
With docPolicy
  .Save
  .SaveAs FileName:="C:\kcm\test.doc"
  .Close
End With
Set docPolicy = Nothing
End Sub


0
 
mdouganCommented:
Actually, you only need to include the reference to the word object library if you use the original syntax of:

Dim docPolicy As Word.Document

If you use the suggested syntax of:

Set docPolicy = CreateObject("Word.Document")

Then you don't need to specify the reference to the library.  I would recommend the latter, because if you set a reference to the library, you are picking a specific version of the Word object library, and, if the client doesn't have that specific version of Word, then they will get this same error.

0
 
mdouganCommented:
As far as specifying the encoding, I think that it's one of the parameters in the open statement:

expression.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible)

I'm not sure if you need to set the Format or the Encoding parameter, here is an example setting the Format parameter, I can't find any help on setting the Encoding parameter....

Set wrdDoc = wrdApp.Documents.Open("H:\Code\test.txt",,,,,,,,,wdOpenFormatEncodedText)
0
 
AmitabhAuthor Commented:
thanx all of you for your support.

createobject is working fine and mdougan thanx for telling us the reason.

Regards
A.Pandey
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now