Solved

insert file

Posted on 2003-11-21
10
758 Views
Last Modified: 2012-08-14
hi
I want to insert *.txt file to word document using VBA without ConfirmConversions

Sub Makro1()
     Selection.InsertFile FileName:="a2.txt", ConfirmConversions:=false
End Sub

The problem is:  Word sometimes interprets txt file (with txt extension) as HTML document.
For example, if file wherever contain string "<table>" word will interpred file as HTML (no matter that file is without </table> <html>, but if file contains <h2> gfghjfjreeee </h2> it is interpreted as text.)

So, I want to force Word to interprete any file with .txt extension as text without using ConfirmConversions:=true.




0
Comment
Question by:jsemenak
10 Comments
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9796646
What version of Word?
0
 
LVL 9

Author Comment

by:jsemenak
ID: 9796699
Word 2000
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9796749
Under Tools, Options, General - is "confirm conversion at open" unchecked?  If so you shouldn't even need the ConfirmConversions code.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 9

Author Comment

by:jsemenak
ID: 9797038
Problem is not with ConfirmConversions
I can state in VBA for do or don't do it.
I want to have ConfirmConversions = false, It is not problem.

Problem is  that word sometimes intrepretes txt file (with *.txt extension) as html. So I want to use convertor for txt.
If I select manualy from ConfirmConversions dialog  -Only Text
I will get good result, but if I don't use confirmation word badlz intrerprete txt file as html.
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9797245
Not sure if I know how to do that without having the conversion box come up.  Will think about it.  In the meantime, maybe someone else here will be able to help you.
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9797554
OK - I tried this - even with Tools, Options, Confirm Conversion at open to be true - this worked for me:

    Application.DisplayAlerts = wdAlertsNone
    Selection.InsertFile FileName:="yourfile", Range:="", _
        ConfirmConversions:=False, Link:=False, Attachment:=False

Hope it works for you too
0
 
LVL 9

Author Comment

by:jsemenak
ID: 9809116
Steel not good.
Code with Application.DisplayAlerts = wdAlertsNone
or withou this work identicaly.

I have in my txt file named a.txt this:

vlozit
<table>
obr1

I want to get this, but  using  this I get

vlozit
obr1

where obr1 is in new created table, because of word using wrong file converter.

It is clear, that your code can't influance strange and stupid word intelligence which interpretes txt file as HTML (especially in case when contained text is not valid HTML code) Do you test your code for txt file containing string <table>?
In may computer this don't work correctly.

So I have to force word to use correct convertor for txt. This convertor have index1.
Fileconverters(1)
I must select this convertor without any manual work (because I want to insert a lot of txt files). The possible way is automatically choose first item from the list in confirmation dialog, but I do not know code for this and in InsertFile is not any parameter determining which converter has to be used.
 
If I will not find how to force Word to use convertor I have to use statment Open Read Close.



0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9933978
0
 
LVL 10

Expert Comment

by:daleoran
ID: 10391687
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ: No Refund

Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Daleoran
EE Cleanup Volunteer
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 10424941
PAQed - no points refunded (of 100)

PashaMod
Community Support Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

828 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