Solved

insert file

Posted on 2003-11-21
10
759 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: 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.

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

763 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