Solved

insert file

Posted on 2003-11-21
10
769 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
[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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.

617 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