?
Solved

A challenging question for experts

Posted on 2002-07-03
7
Medium Priority
?
214 Views
Last Modified: 2010-05-02
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
Comment
Question by:Amitabh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 7128879
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
 
LVL 5

Expert Comment

by:kcm76
ID: 7129190
** 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
 

Author Comment

by:Amitabh
ID: 7131103
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Accepted Solution

by:
kcm76 earned 400 total points
ID: 7131200
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
 
LVL 18

Expert Comment

by:mdougan
ID: 7132032
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
 
LVL 18

Expert Comment

by:mdougan
ID: 7132055
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
 

Author Comment

by:Amitabh
ID: 7136610
thanx all of you for your support.

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

Regards
A.Pandey
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question