View Single Post
  #13   Report Post  
Kenneth
 
Posts: n/a
Default

On Tue, 10 May 2005 19:06:16 -0400, Kenneth
wrote:

On Tue, 10 May 2005 23:15:58 +0200, "Klaus Linke"
wrote:




I want to prevent that from happening, that is, I would like
to set a default in Word, to open all TXT files with a
particular conversion rather than choosing each time.

Now, it happens that I want that not merely to avoid having
to make the selection. I have a Word macro that formats and
prints the TXT file in a certain way and when the macro
runs, the conversion dialog stops it. It would appear that
the problem could be solved either by having the default
that I described, or by inserting something in the macro
that would tell Word (in effect) Open the TXT file converted
as "Plain Text."

In addition, there might be other approaches, but either of
those above would give me what I need.

Sincere thanks once again,
--
Kenneth

If you email... Please remove the "SPAMLESS."


If I launch Word 2000 and try to open the TXT file (or if I
open a new DOC and attempt to insert the TXT file) a dialog
opens in Word that asks how I want the TXT file converted.


Does your macro contain ".ConfirmConversions:=True"?
Then change that to ".ConfirmConversions:=False".

Or didn't you uncheck "Tools Options General Always confirm conversions"?
If you want the macro to work anyway without showing the dialog, you can "uncheck" that option in your macro.

Insert

Dim boolConfirmConversions as Boolean
boolConfirmConversions=Options.ConfirmConversions
Options.ConfirmConversions = False

before the macro tries to open/insert the file, and

Options.ConfirmConversions = boolConfirmConversions

(to reset the option to its previous setting) after the macro has opened/inserted the file.

If some characters are changed to blanks, either your database isn't writing Windows text files (code page 1252), or Word uses the wrong encoding when opening the text file.
You can check the latter if you let the macro open the file, and then open the VBA editor (Alt+F11), go to the immediate window (Ctrl+G), type
? ActiveDocument.OpenEncoding
and hit Return. You should get
1252
for the Windows code page 1252.

If you get something different, you could use the code from the KB article, but using
.Encoding:=msoEncodingWestern
to make sure the Windows code page is used.

If you got 1252, maybe we can figure out what code page your database exports if you list some characters from the database, and what they turn into in Word.

(BTW, I can't see how you can get an error message about HKEY_LOCAL_MACHINE, since the macro doesn't contain that string. Maybe it's coming from some other macro of yours?)

Regards,
Klaus


Hi again Klaus,

Using the method you described, I see that Word is using
code page 1200 when I open the TXT file, so that is no doubt
the source of the problem I am having. Why might that be
happening?

With regard to the HKEY_LOCAL_MACHINE error, when I step
through the EditConversionOptions macro it eventually calls
a subroutine as below:

'----------------------------------------------------
'--- initialize the combo box with conveter names ---
'----------------------------------------------------

Public Function ControlsInit() As Boolean

' fill the combo with text converters and graphics
filters
ListConverters hCnvExpKeyHandle, HKEY_LOCAL_MACHINE, _
strREG_TEXT_CNV_EXPORT, strREG_CNV_NAME
ListConverters hCnvImpKeyHandle, HKEY_LOCAL_MACHINE, _
strREG_TEXT_CNV_IMPORT, strREG_CNV_NAME
ListConverters hFltExpKeyHandle, HKEY_LOCAL_MACHINE, _
strREG_GRAPH_FLT_EXPORT, strREG_CNV_NAME
ListConverters hFltImpKeyHandle, HKEY_LOCAL_MACHINE, _
strREG_GRAPH_FLT_IMPORT, strREG_CNV_NAME





Next, I have experimented with the line you offered
(.Encoding:=msoEncodingWestern) but keep getting syntax
errors.

My macro appears below. Might you show me how that line
should be used?



Sub RosterCheck()
' RosterCheck Macro
'
Documents.Add DocumentType:=wdNewBlankDocument
Selection.InsertFile FileName:="Z:\data\ROSTER.TXT",
Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
Selection.HomeKey Unit:=wdLine
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1.1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1.25)
.RightMargin = InchesToPoints(1.25)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With
With Selection.Font
.Name = "Comic Sans MS"
.Size = 12
End With
Application.PrintOut FileName:="",
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False,
PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0,
PrintZoomPaperHeight:=0
End Sub



As before, I sincerely appreciate your help,



Hello again,

I neglected to say that "Tools Options General Always
confirm conversions" is NOT checked, but still, when I
attempt to open a TXT file, the conversion dialog opens.

I also had experimented including in my macro
ConfirmConversions:=False or "True" but nothing changed.

Thanks again,
--
Kenneth

If you email... Please remove the "SPAMLESS."