Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

insert file

Posted on 2003-11-21
10
Medium Priority
?
773 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Suggested Courses

705 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