Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

A challenging question for experts

Posted on 2002-07-03
7
Medium Priority
?
216 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

597 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