File converter

C

Carol Grismore

When I try to run this code (from MS web site):
---------------------------------------------------------------------------
Sub GetConvClassName()

Dim fcCnv As FileConverter

' Create blank document.
Documents.Add

' Loop through all installed converters.
For Each fcCnv In FileConverters
With fcCnv
' If the converter can be used to save...
If .CanSave = True Then
' Insert the converter name and class name in the document.
Selection.TypeText "Converter: " & .FormatName & vbTab _
& "ClassName: " & .ClassName & vbCr
End If

End With

Next fcCnv

End Sub
--------------------------------------------------------------------
I get a message that says:
"Compile error: User-defined type not defined".
The message refers to the
Dim fcCnv As FileConverter
statement.

Do I have to activate a special REFERENCE in order to make this subroutine
work?

Ultimately, I'd like to open a Word document and save it as a .txt file, but
I'm not going to be able to do that unless the file converter will work. I
didn't find anything that I recognized as useful in the Knowledge Base.

Any suggestions are deeply appreciated.
 
D

Dirk Goldgar

Carol Grismore said:
When I try to run this code (from MS web site):
---------------------------------------------------------------------------
Sub GetConvClassName()

Dim fcCnv As FileConverter

' Create blank document.
Documents.Add

' Loop through all installed converters.
For Each fcCnv In FileConverters
With fcCnv
' If the converter can be used to save...
If .CanSave = True Then
' Insert the converter name and class name in the document.
Selection.TypeText "Converter: " & .FormatName & vbTab _
& "ClassName: " & .ClassName & vbCr
End If

End With

Next fcCnv

End Sub
--------------------------------------------------------------------
I get a message that says:
"Compile error: User-defined type not defined".
The message refers to the
Dim fcCnv As FileConverter
statement.

Do I have to activate a special REFERENCE in order to make this subroutine
work?

Ultimately, I'd like to open a Word document and save it as a .txt file,
but
I'm not going to be able to do that unless the file converter will work.
I
didn't find anything that I recognized as useful in the Knowledge Base.


Are you trying to run this code from Access? I think I've found the KB
article you got the code from, but that artice applies to Microsoft Word,
which (I gather) has a built-in FileConverter object and FileConverters
collection. If you need to use those objects from Access, I think you'll
probably have to create and automate an instance of Word.
 
C

Carol Grismore

<blush>
Oh, well -- your mention of Word solved my problem, so thanks for that.
Turns out all I needed was an additional REFERENCE. The code still doesn't
produce anything, but the TYPE is now recognized and doesn't generate an
error.

The conversion from .doc to .txt, which was the whole point of the exercise,
is now working, due to the REFERENCE that your post prompted me to add to my
project.

So -- hearty thanks to you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top