Reply
 
Thread Tools Display Modes
  #1   Report Post  
Kenneth
 
Posts: n/a
Default Setting the default encoding...?


Howdy,

When I open a TXT file in Word 2000 (or insert a TXT file in
another open DOC) a dialog opens asking how I want the
characters in the file converted.

How can I set the default to a particular conversion so that
the dialog does not open each time?

Sincere thanks,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #2   Report Post  
Bob Buckland ?:-\)
 
Posts: n/a
Default

Hi Kenneth,

This article may help:
http://support.microsoft.com/default...us;256060&FR=1

========
"Kenneth" wrote in message ...

Howdy,

When I open a TXT file in Word 2000 (or insert a TXT file in
another open DOC) a dialog opens asking how I want the
characters in the file converted.

How can I set the default to a particular conversion so that
the dialog does not open each time?

Sincere thanks,

Kenneth
--
Let us know if this helped you,

Bob Buckland ?:-)
MS Office System Products MVP

*Courtesy is not expensive and can pay big dividends*

Office 2003 Editions explained
http://www.microsoft.com/uk/office/editions.mspx


  #3   Report Post  
Kenneth
 
Posts: n/a
Default

On Tue, 10 May 2005 10:03:42 -0700, "Bob Buckland ?:-\)"
75214.226(At Beautiful Downtown)compuserve.com wrote:

Hi Kenneth,

This article may help:
http://support.microsoft.com/default...us;256060&FR=1

========
"Kenneth" wrote in message ...

Howdy,

When I open a TXT file in Word 2000 (or insert a TXT file in
another open DOC) a dialog opens asking how I want the
characters in the file converted.

How can I set the default to a particular conversion so that
the dialog does not open each time?

Sincere thanks,

Kenneth


Hi Bob,

I appreciate your response, but...

I had found that article on my own. I made the registry
modification as described, re-booted, but still had the
problem.

Do you know if there was something beyond the reg hack that
I was to have done?

Thanks again,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #4   Report Post  
Bob Buckland ?:-\)
 
Posts: n/a
Default

Hi Kenneth,

Did you use the macro technique in method 1?

=======
"Kenneth" wrote in message ...
Hi Bob,

I appreciate your response, but...

I had found that article on my own. I made the registry
modification as described, re-booted, but still had the
problem.

Do you know if there was something beyond the reg hack that
I was to have done?

Thanks again,
--
Kenneth
--
Bob Buckland ?:-)
MS Office System Products MVP

*Courtesy is not expensive and can pay big dividends*


  #5   Report Post  
Klaus Linke
 
Posts: n/a
Default

Hi Kenneth,

You must have seen a different KB article. And I don't think there is a =
registry setting for a default "open" encoding, since such a default =
setting would be a terrible idea.

You can use a macro to open text files using the specific encoding you =
want (maybe using some more sophisticated macro than the one from the KB =
article, which lets you specify the file using the "File Open" =
dialog).

You can even replace the "File Open" dialog with your sophisticated =
macro (though I wouldn't do that).

You can't set a default encoding for text files. The default in Windows =
apps is the Windows code page, or Unicode.
Either you let Word guess (with "confirm conversions" turned off), which =
will work for Windows text files and Unicode text files, or you'll have =
to specify the encoding (manually or by writing a macro).

Regards,
Klaus


"Kenneth" wrote:
On Tue, 10 May 2005 10:03:42 -0700, "Bob Buckland ?:-\)"
75214.226(At Beautiful Downtown)compuserve.com wrote:
=20
Hi Kenneth,

This article may help:
=

http://support.microsoft.com/default...;256060&FR=3D1

=3D=3D=3D=3D=3D=3D=3D=3D
"Kenneth" wrote in message =

...

Howdy,

When I open a TXT file in Word 2000 (or insert a TXT file in
another open DOC) a dialog opens asking how I want the
characters in the file converted.

How can I set the default to a particular conversion so that
the dialog does not open each time?

Sincere thanks,

Kenneth

=20
Hi Bob,
=20
I appreciate your response, but...
=20
I had found that article on my own. I made the registry
modification as described, re-booted, but still had the
problem.
=20
Do you know if there was something beyond the reg hack that
I was to have done?
=20
Thanks again,
--=20
Kenneth
=20
If you email... Please remove the "SPAMLESS."



  #6   Report Post  
Kenneth
 
Posts: n/a
Default

On Tue, 10 May 2005 11:00:58 -0700, "Bob Buckland ?:-\)"
75214.226(At Beautiful Downtown)compuserve.com wrote:

Hi Kenneth,

Did you use the macro technique in method 1?

=======
"Kenneth" wrote in message ...
Hi Bob,

I appreciate your response, but...

I had found that article on my own. I made the registry
modification as described, re-booted, but still had the
problem.

Do you know if there was something beyond the reg hack that
I was to have done?

Thanks again,
--
Kenneth


Hi Bob,

Well I "tried" the Macro technique...

I got the file with the macros, but when I attempted to run
the appropriate one, it did not succeed (with regret, I
cannot remember the precise error.)

In summary, "No" I did not run the macro.

Thanks again,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #7   Report Post  
Kenneth
 
Posts: n/a
Default

On Tue, 10 May 2005 20:33:26 +0200, "Klaus Linke"
wrote:



"Kenneth" wrote:
On Tue, 10 May 2005 10:03:42 -0700, "Bob Buckland ?:-\)"
75214.226(At Beautiful Downtown)compuserve.com wrote:

Hi Kenneth,

This article may help:
http://support.microsoft.com/default...us;256060&FR=1

========
"Kenneth" wrote in message ...

Howdy,

When I open a TXT file in Word 2000 (or insert a TXT file in
another open DOC) a dialog opens asking how I want the
characters in the file converted.

How can I set the default to a particular conversion so that
the dialog does not open each time?

Sincere thanks,

Kenneth


Hi Bob,

I appreciate your response, but...

I had found that article on my own. I made the registry
modification as described, re-booted, but still had the
problem.

Do you know if there was something beyond the reg hack that
I was to have done?

Thanks again,
--
Kenneth

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


Hi Kenneth,

You must have seen a different KB article. And I don't think there is a registry setting for a default "open" encoding, since such a default setting would be a terrible idea.

You can use a macro to open text files using the specific encoding you want (maybe using some more sophisticated macro than the one from the KB article, which lets you specify the file using the "File Open" dialog).

You can even replace the "File Open" dialog with your sophisticated macro (though I wouldn't do that).

You can't set a default encoding for text files. The default in Windows apps is the Windows code page, or Unicode.
Either you let Word guess (with "confirm conversions" turned off), which will work for Windows text files and Unicode text files, or you'll have to specify the encoding (manually or by writing a macro).

Regards,
Klaus


Hi Klaus,

It is only for TXT files that I would like to set a default
encoding.

Is there a way to do that?

Or, if I wish to have Word "guess", is there a way to have
it do that?

Thanks again,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #8   Report Post  
Klaus Linke
 
Posts: n/a
Default

Hi Kenneth,

I'd like to take a step back, because I'm still not sure what you are =
trying to do.
The (recoded) macro you posted in the other thread contained =
"InsertFile".
I don't see how you can specify the encoding for "InsertFile", either.

Here, you're talking about "File Open", where you can specify the =
encoding.
But I'm not sure why you'd need to (either opening or inserting a text =
file).

As far as I understood, you're saving the text files yourself.=20
If you use "Plain text" (=3D Windows text) for saving the text file, you =
shouldn't need to specify any encoding when you re-open or insert the =
file.=20
And if the "Confirm conversions" dialog (in "File Open" or "Insert =
File") bothers you, you should be able to turn that off.

In this thread, you said that the "Confirm conversion" dialog comes up. =
Did you uncheck the option in "Tools General" and it still comes up? =
Then maybe that's the bug that might be solved by the hotfix from =
http://support.microsoft.com/kb/817140
(Can't say for sure because I've never run into this bug)

In the other thread, you said that some characters change into blanks if =
you re-open the text file.
Are you sure those characters *can* be saved in a Windows plain text =
file? Which characters are turned into blanks?

Regards,
Klaus



"Kenneth" schrieb im Newsbeitrag =
...
On Tue, 10 May 2005 20:33:26 +0200, "Klaus Linke"
wrote:
=20
=20

"Kenneth" wrote:
On Tue, 10 May 2005 10:03:42 -0700, "Bob Buckland ?:-\)"
75214.226(At Beautiful Downtown)compuserve.com wrote:
=20
Hi Kenneth,

This article may help:
=

http://support.microsoft.com/default...;256060&FR=3D1

=3D=3D=3D=3D=3D=3D=3D=3D
"Kenneth" wrote in message =

...

Howdy,

When I open a TXT file in Word 2000 (or insert a TXT file in
another open DOC) a dialog opens asking how I want the
characters in the file converted.

How can I set the default to a particular conversion so that
the dialog does not open each time?

Sincere thanks,

Kenneth
=20
Hi Bob,
=20
I appreciate your response, but...
=20
I had found that article on my own. I made the registry
modification as described, re-booted, but still had the
problem.
=20
Do you know if there was something beyond the reg hack that
I was to have done?
=20
Thanks again,
--=20
Kenneth
=20
If you email... Please remove the "SPAMLESS."

=20
Hi Kenneth,

You must have seen a different KB article. And I don't think there is =

a registry setting for a default "open" encoding, since such a default =
setting would be a terrible idea.

You can use a macro to open text files using the specific encoding =

you want (maybe using some more sophisticated macro than the one from =
the KB article, which lets you specify the file using the "File Open" =
dialog).

You can even replace the "File Open" dialog with your sophisticated =

macro (though I wouldn't do that).

You can't set a default encoding for text files. The default in =

Windows apps is the Windows code page, or Unicode.
Either you let Word guess (with "confirm conversions" turned off), =

which will work for Windows text files and Unicode text files, or you'll =
have to specify the encoding (manually or by writing a macro).

Regards,
Klaus

=20
Hi Klaus,
=20
It is only for TXT files that I would like to set a default
encoding.
=20
Is there a way to do that?
=20
Or, if I wish to have Word "guess", is there a way to have
it do that?
=20
Thanks again,
--=20
Kenneth
=20
If you email... Please remove the "SPAMLESS."

  #9   Report Post  
Kenneth
 
Posts: n/a
Default

On Tue, 10 May 2005 14:44:02 -0400, Kenneth
wrote:

On Tue, 10 May 2005 11:00:58 -0700, "Bob Buckland ?:-\)"
75214.226(At Beautiful Downtown)compuserve.com wrote:

Hi Kenneth,

Did you use the macro technique in method 1?

=======
"Kenneth" wrote in message ...
Hi Bob,

I appreciate your response, but...

I had found that article on my own. I made the registry
modification as described, re-booted, but still had the
problem.

Do you know if there was something beyond the reg hack that
I was to have done?

Thanks again,
--
Kenneth


Hi Bob,

Well I "tried" the Macro technique...

I got the file with the macros, but when I attempted to run
the appropriate one, it did not succeed (with regret, I
cannot remember the precise error.)

In summary, "No" I did not run the macro.

Thanks again,


Hi again Bob,

I just tried to run the macro again.

The Word Basic error is

Compile Error:

Ambiguous name detected HKEY_LOCAL_MACHINE

Thanks for any further thoughts,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #10   Report Post  
Kenneth
 
Posts: n/a
Default

On Tue, 10 May 2005 22:09:28 +0200, "Klaus Linke"
wrote:

Hi Kenneth,

I'd like to take a step back, because I'm still not sure what you are trying to do.
The (recoded) macro you posted in the other thread contained "InsertFile".
I don't see how you can specify the encoding for "InsertFile", either.

Here, you're talking about "File Open", where you can specify the encoding.
But I'm not sure why you'd need to (either opening or inserting a text file).

As far as I understood, you're saving the text files yourself.
If you use "Plain text" (= Windows text) for saving the text file, you shouldn't need to specify any encoding when you re-open or insert the file.
And if the "Confirm conversions" dialog (in "File Open" or "Insert File") bothers you, you should be able to turn that off.

In this thread, you said that the "Confirm conversion" dialog comes up. Did you uncheck the option in "Tools General" and it still comes up? Then maybe that's the bug that might be solved by the hotfix from http://support.microsoft.com/kb/817140
(Can't say for sure because I've never run into this bug)

In the other thread, you said that some characters change into blanks if you re-open the text file.
Are you sure those characters *can* be saved in a Windows plain text file? Which characters are turned into blanks?

Regards,
Klaus



"Kenneth" schrieb im Newsbeitrag ...
On Tue, 10 May 2005 20:33:26 +0200, "Klaus Linke"
wrote:



"Kenneth" wrote:
On Tue, 10 May 2005 10:03:42 -0700, "Bob Buckland ?:-\)"
75214.226(At Beautiful Downtown)compuserve.com wrote:

Hi Kenneth,

This article may help:
http://support.microsoft.com/default...us;256060&FR=1

========
"Kenneth" wrote in message ...

Howdy,

When I open a TXT file in Word 2000 (or insert a TXT file in
another open DOC) a dialog opens asking how I want the
characters in the file converted.

How can I set the default to a particular conversion so that
the dialog does not open each time?

Sincere thanks,

Kenneth

Hi Bob,

I appreciate your response, but...

I had found that article on my own. I made the registry
modification as described, re-booted, but still had the
problem.

Do you know if there was something beyond the reg hack that
I was to have done?

Thanks again,
--
Kenneth

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


Hi Kenneth,

You must have seen a different KB article. And I don't think there is a registry setting for a default "open" encoding, since such a default setting would be a terrible idea.

You can use a macro to open text files using the specific encoding you want (maybe using some more sophisticated macro than the one from the KB article, which lets you specify the file using the "File Open" dialog).

You can even replace the "File Open" dialog with your sophisticated macro (though I wouldn't do that).

You can't set a default encoding for text files. The default in Windows apps is the Windows code page, or Unicode.
Either you let Word guess (with "confirm conversions" turned off), which will work for Windows text files and Unicode text files, or you'll have to specify the encoding (manually or by writing a macro).

Regards,
Klaus


Hi Klaus,

It is only for TXT files that I would like to set a default
encoding.

Is there a way to do that?

Or, if I wish to have Word "guess", is there a way to have
it do that?

Thanks again,
--
Kenneth

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


Hi Kenneth,

I'd like to take a step back, because I'm still not sure what you are trying to do.
The (recoded) macro you posted in the other thread contained "InsertFile".
I don't see how you can specify the encoding for "InsertFile", either.

Here, you're talking about "File Open", where you can specify the encoding.
But I'm not sure why you'd need to (either opening or inserting a text file).

As far as I understood, you're saving the text files yourself.
If you use "Plain text" (= Windows text) for saving the text file, you shouldn't need to specify any encoding when you re-open or insert the file.
And if the "Confirm conversions" dialog (in "File Open" or "Insert File") bothers you, you should be able to turn that off.

In this thread, you said that the "Confirm conversion" dialog comes up. Did you uncheck the option in "Tools General" and it still comes up? Then maybe that's the bug that might be solved by the hotfix from http://support.microsoft.com/kb/817140
(Can't say for sure because I've never run into this bug)

In the other thread, you said that some characters change into blanks if you re-open the text file.
Are you sure those characters *can* be saved in a Windows plain text file? Which characters are turned into blanks?

Regards,
Klaus


Hi Klaus,

My apologies for any confusion...

Let's start with the macro that I posted:

I recorded those two macros only so that I could see the
code that might do what I needed. Other than that, the
macros are of no significance.

So, let me describe again what it is that I am trying to do:

I have a TXT file. (It happens that the file is written by
my database, but, as with the issue of the macros, I believe
that to be of no relevance here.)

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.

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."


  #11   Report Post  
Klaus Linke
 
Posts: n/a
Default

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:=3DTrue"?
Then change that to ".ConfirmConversions:=3DFalse".

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=3DOptions.ConfirmConversion s
Options.ConfirmConversions =3D False

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

Options.ConfirmConversions =3D 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:=3DmsoEncodingWestern
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



=20
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.
=20
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."
=20
In addition, there might be other approaches, but either of
those above would give me what I need.
=20
Sincere thanks once again,=20
--=20
Kenneth
=20
If you email... Please remove the "SPAMLESS."

  #12   Report Post  
Kenneth
 
Posts: n/a
Default

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,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #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."
  #14   Report Post  
Kenneth
 
Posts: n/a
Default

On Tue, 10 May 2005 19:21:49 -0400, Kenneth
wrote:

HUGE SNIP


Hi yet again,

I just experimented further:

I created and saved a completely new TXT file in Notepad,
and saved it. It included some upper ASCII characters.

When I attempt to open it in Word 2002 (I have that on
another system) I get the familiar conversion dialog box.

So, for some reason, neither W2000 nor W2002 can simply open
these TXT files.

Thanks again,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #15   Report Post  
Klaus Linke
 
Posts: n/a
Default

Hi Kenneth,

The Encoding was meant to be used in the macro from the KB article:

' Replace the FileName example with the path to your text file.
Documents.Open FileName:=3D"Z:\data\ROSTER.TXT", _
Format:=3DwdOpenFormatText, Encoding:=3DmsoEncodingWestern

As there doesn't seem to be a way to specify the encoding for =
InsertFile, I'd open the text file as a new document with the code =
above, and then copy/paste it into your document.

The code you posted (re HKEY_LOCAL_MACHINE) is from the =
EditConversionOptions macro (support9.dot)?
I don't think you need that.

If it's not confidential, you might mail the text file to my private =
mail address, so I can experiment a bit.
Probably Word (Insert File) tries to guess the encoding from the =
characters used in the text file, and is thrown off by some unusual =
characters in the text file.=20

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?


1200 is for Unicode and usual for a Word doc. I guess you used "Insert =
File", not "File Open"?
Then 1200 isn't surprising.

Regards,
Klaus


  #16   Report Post  
Kenneth
 
Posts: n/a
Default

On Wed, 11 May 2005 03:02:33 +0200, "Klaus Linke"
wrote:

Hi Kenneth,

The Encoding was meant to be used in the macro from the KB article:

' Replace the FileName example with the path to your text file.
Documents.Open FileName:="Z:\data\ROSTER.TXT", _
Format:=wdOpenFormatText, Encoding:=msoEncodingWestern

As there doesn't seem to be a way to specify the encoding for InsertFile, I'd open the text file as a new document with the code above, and then copy/paste it into your document.

The code you posted (re HKEY_LOCAL_MACHINE) is from the EditConversionOptions macro (support9.dot)?
I don't think you need that.

If it's not confidential, you might mail the text file to my private mail address, so I can experiment a bit.
Probably Word (Insert File) tries to guess the encoding from the characters used in the text file, and is thrown off by some unusual characters in the text file.

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?


1200 is for Unicode and usual for a Word doc. I guess you used "Insert File", not "File Open"?
Then 1200 isn't surprising.

Regards,
Klaus


Hi again Klaus,

The problem is solved thanks to your kind help!!

Documents.Open FileName:="Z:\data\ROSTER.TXT", _
Format:=wdOpenFormatText, Encoding:=msoEncodingWestern

fixed the problem...

One question though:

What is the " _ " character that appears at the end of the
first line?

I will also add that I may have confused things when I
mentioned the issue of inserting (rather than opening) the
file.

I had added that only because I thought that it might help
in diagnosing the problem. I have no need to actually do
this by inserting. The modified macro now works perfectly by
opening the file.

Sincere thanks yet again,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #17   Report Post  
Klaus Linke
 
Posts: n/a
Default

What is the " _ " character that appears at the end of the
first line?


It tells VBA that the line is continued on the next line.

Great that the problem is solved! I was starting to be afraid it might =
be some bug in Word.

Regards,
Klaus
  #18   Report Post  
Kenneth
 
Posts: n/a
Default

On Wed, 11 May 2005 20:19:40 +0200, "Klaus Linke"
wrote:

What is the " _ " character that appears at the end of the
first line?


It tells VBA that the line is continued on the next line.

Great that the problem is solved! I was starting to be afraid it might be some bug in Word.

Regards,
Klaus


Hi Klaus,

The only bug was (apparently) in me...g!

All the best,
--
Kenneth

If you email... Please remove the "SPAMLESS."
  #19   Report Post  
Matz
 
Posts: n/a
Default

hi guys,

I'm new here and I have a similar problem like Kenneth had...

the only problem is that I'm a LAN administrator "TRYING" to solve a
programmer's problem.

when they do the mailmerge into word, the french characters come out as
Japanese characters. (It automatically selects the japanese one)

now I noticed that Z:data thing .. but is that some sort of generic coding
or are you guys working at the same place and using the same drives and all
... (please be easy on me.. I'm not really good in programming stuff!)

thank you very much for any help!

****

"Kenneth" wrote:

On Wed, 11 May 2005 20:19:40 +0200, "Klaus Linke"
wrote:

What is the " _ " character that appears at the end of the
first line?


It tells VBA that the line is continued on the next line.

Great that the problem is solved! I was starting to be afraid it might be some bug in Word.

Regards,
Klaus


Hi Klaus,

The only bug was (apparently) in me...g!

All the best,
--
Kenneth

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

  #20   Report Post  
Matz
 
Posts: n/a
Default

yeah.. please ignore my message...

I didn'T read the REPLACE FILE NAME...


forum newbie!

thanks anyways!


"Matz" wrote:

hi guys,

I'm new here and I have a similar problem like Kenneth had...

the only problem is that I'm a LAN administrator "TRYING" to solve a
programmer's problem.

when they do the mailmerge into word, the french characters come out as
Japanese characters. (It automatically selects the japanese one)

now I noticed that Z:data thing .. but is that some sort of generic coding
or are you guys working at the same place and using the same drives and all
.. (please be easy on me.. I'm not really good in programming stuff!)

thank you very much for any help!

****

"Kenneth" wrote:

On Wed, 11 May 2005 20:19:40 +0200, "Klaus Linke"
wrote:

What is the " _ " character that appears at the end of the
first line?

It tells VBA that the line is continued on the next line.

Great that the problem is solved! I was starting to be afraid it might be some bug in Word.

Regards,
Klaus


Hi Klaus,

The only bug was (apparently) in me...g!

All the best,
--
Kenneth

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

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
default font setting for Document Map sflworduser Microsoft Word Help 1 May 2nd 05 05:35 AM
*Permanent* Default Tab Setting Zigmund Microsoft Word Help 6 April 19th 05 08:20 AM
Default Font, etc. setting M_Kline Microsoft Word Help 1 March 23rd 05 04:39 PM
Default font - possible bulletproof fix in Word 2003 [email protected] Microsoft Word Help 0 January 14th 05 10:14 PM
change view track changes default setting Clarke Microsoft Word Help 1 December 9th 04 09:32 PM


All times are GMT +1. The time now is 11:53 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"