Home |
Search |
Today's Posts |
#1
|
|||
|
|||
danish letters
Hi
Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#2
|
|||
|
|||
I suggest you try the following instead, but use the pathname of the folder
containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. ..OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#3
|
|||
|
|||
This may sound as a stupid question: What is Text Driver DSN on system?
"Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. ..OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#4
|
|||
|
|||
It is something you have to have to use an ODBC (Open DataBase Connectivity)
data source. Word can read a text data source using a number of different methods, including a. its own internal text converter b. ODBC c. OLEDB d. indirectly, e.g. using Excel (the method you were using) All these methods suffer from various problems, but in this case I believe the ODBC method is most likely to work. However, it does require that you have ODBC on your system, which I believe you will have by default. if you do not, and you need to distribute your solution, other approaches begin to look better, But to check, go into Windows Control Panel and look for Performance and Maintenance|Administrative Tools|Data Sources (ODBC), or just Administrative Tools|Data Sources (ODBC), and look in the User DSN tab for "Delimited Text Files". if you do not see it, click Add, find Microsoft Text Driver, fill in the details, and take it from there. Peter Jamieson "bilisa" wrote in message ... This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. ..OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#5
|
|||
|
|||
I followed your instructions, but I still have the same problem. It seems to
me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. ..OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#6
|
|||
|
|||
Sorry, my mistake. I still think it can be done, but right now I can only
check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#7
|
|||
|
|||
I tried with your suggestions, but same result.. hope we can crack this one
"Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#8
|
|||
|
|||
The strange thing sbout it is that I have two .csv data files both containing
ø,æ,å etc. and have the same structure, but they behave differently when merged with the same document!?!?! "Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#9
|
|||
|
|||
That would not surprise me if the encoding was different (e.g. one is
encoded using Unicode and the other using Windows/ANSI). You can test some of that by opening the file in Notepad and saving it using the different encodings Notepad supports - or you can open in Word and save as encoded text. Peter Jamieson "bilisa" wrote in message ... The strange thing sbout it is that I have two .csv data files both containing ø,æ,å etc. and have the same structure, but they behave differently when merged with the same document!?!?! "Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#10
|
|||
|
|||
I changed the encoding from ANSI to Unicode which solved the problem. So now
I have located the problem. Next how to sove it with vba when doing a mailmerge. Alternatively I can export my files using unicode encoding, but I dont know if its possible.. "Peter Jamieson" wrote: That would not surprise me if the encoding was different (e.g. one is encoded using Unicode and the other using Windows/ANSI). You can test some of that by opening the file in Notepad and saving it using the different encodings Notepad supports - or you can open in Word and save as encoded text. Peter Jamieson "bilisa" wrote in message ... The strange thing sbout it is that I have two .csv data files both containing ø,æ,å etc. and have the same structure, but they behave differently when merged with the same document!?!?! "Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#11
|
|||
|
|||
OK, I managed to check some things on a WordXP system again. Can you try the
same as before, but use wdMergeSubtypeWord2000 instead of wdMergeSubtypeOther ? (That's what I thought it should be under Word 2002 but it didn't seem to work under Word 2003) Another ODBC is to create a file DSN and use that to access the file. You can create a file DSN in the ODBC Administrator we looked at earlier, but you can also do it in Wordpad as long as you know the exact name of the Driver (it's the name that appears in the list when you create a new DSN in ODBC). For example, create the following file in Notepad and save it as c:\filedsns\mydsn.dsn [ODBC] DRIVER=Microsoft Text Driver (*.txt; *.csv) PageTimeout=5 MaxBufferSize=2048 FIL=text DriverID=27 Then use this code: ..OpenDataSource _ Name:="c:\filedsns\mydsn.dsn", _ Connection:="FILEDSN=c:\filedsns\mydsn.dsn;", _ SQLStatement:="SELECT * FROM ktext.text", _ SubType:=wsMergeSubTypeWord2000 That's my last attempt for tonight! Peter Jamieson "bilisa" wrote in message ... I tried with your suggestions, but same result.. hope we can crack this one "Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#12
|
|||
|
|||
If you use Unicode I don't think the ODBC approach will work properly, BTW.
But I'm not completely sure. Peter Jamieson "bilisa" wrote in message ... I changed the encoding from ANSI to Unicode which solved the problem. So now I have located the problem. Next how to sove it with vba when doing a mailmerge. Alternatively I can export my files using unicode encoding, but I dont know if its possible.. "Peter Jamieson" wrote: That would not surprise me if the encoding was different (e.g. one is encoded using Unicode and the other using Windows/ANSI). You can test some of that by opening the file in Notepad and saving it using the different encodings Notepad supports - or you can open in Word and save as encoded text. Peter Jamieson "bilisa" wrote in message ... The strange thing sbout it is that I have two .csv data files both containing ø,æ,å etc. and have the same structure, but they behave differently when merged with the same document!?!?! "Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#13
|
|||
|
|||
Maybe I can open my file (during mailmerge) and save it with the proper
encoding.. Something like this: Documents.Open FileName:=filnavn, _ Encoding:="Unicode" Documents.Save Documents.Close "Peter Jamieson" wrote: If you use Unicode I don't think the ODBC approach will work properly, BTW. But I'm not completely sure. Peter Jamieson "bilisa" wrote in message ... I changed the encoding from ANSI to Unicode which solved the problem. So now I have located the problem. Next how to sove it with vba when doing a mailmerge. Alternatively I can export my files using unicode encoding, but I dont know if its possible.. "Peter Jamieson" wrote: That would not surprise me if the encoding was different (e.g. one is encoded using Unicode and the other using Windows/ANSI). You can test some of that by opening the file in Notepad and saving it using the different encodings Notepad supports - or you can open in Word and save as encoded text. Peter Jamieson "bilisa" wrote in message ... The strange thing sbout it is that I have two .csv data files both containing ø,æ,å etc. and have the same structure, but they behave differently when merged with the same document!?!?! "Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#14
|
|||
|
|||
What I meant was that even if your data source is a Unicode Text file, you
may not avoid the encoding dialog that pops up when you open a file. However, if you save as a Word document then use that as a data source, I think you will be OK - if the data source is large, just be prepared for a slow start to the merge. Some sample conversion macros... Sub ConvertToUTF8() ' convert to a UTF8 format text file ' Needs error checking etc. Dim oDoc as Word.Document ' change msoEncodingWestern to be the encoding you need. I think this should work. Set oDoc = Documents.Open("the path name of the file you need to convert.txt", _ False, , False, , , , , , _ wdOpenFormatEncodedText, _ msoEncodingWestern, _ False, False, , True) ' Several of the parameters here are optional or ' irrelevant - you can probably remove the lines from ' ReadOnlyRecommended to SaveAsAOCLetter oDoc.SaveAs _ FileName:="the path name of the file to convert to.txt", _ FileFormat:=wdFormatUnicodeTex*t, _ AddToRecentFiles:=False, _ ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=False*, _ SaveFormsData:=False, _ SaveAsAOCLetter:=False, _ Encoding:=msoEncodingUTF8, _ InsertLineBreaks:=False, _ AllowSubstitutions:=False, _ LineEnding:=wdCRLF oDoc.Close Savechanges:=False Set oDoc = Nothing End Sub or Sub ConvertToWord() ' convert to a Word document file ' Needs error checking etc. Dim oDoc as Word.Document ' change msoEncodingWestern to be the encoding you need. I think this should work. Set oDoc = Documents.Open("the path name of the file you need to convert.txt", _ False, , False, , , , , , _ wdOpenFormatEncodedText, _ msoEncodingWestern, _ False, False, , True) ' Several of the parameters here are optional or ' irrelevant - you can probably remove the lines from ' ReadOnlyRecommended to Encoding oDoc.SaveAs _ FileName:="the path name of the file to convert to.doc", _ FileFormat:=wdFormatDocument, _ AddToRecentFiles:=False, _ ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=False*, _ SaveFormsData:=False, _ SaveAsAOCLetter:=False, _ Encoding:=msoEncodingUTF8, _ InsertLineBreaks:=False, _ AllowSubstitutions:=False, _ LineEnding:=wdCRLF oDoc.Close Savechanges:=False Set oDoc = Nothing End Sub Peter Jamieson "bilisa" wrote in message ... Maybe I can open my file (during mailmerge) and save it with the proper encoding.. Something like this: Documents.Open FileName:=filnavn, _ Encoding:="Unicode" Documents.Save Documents.Close "Peter Jamieson" wrote: If you use Unicode I don't think the ODBC approach will work properly, BTW. But I'm not completely sure. Peter Jamieson "bilisa" wrote in message ... I changed the encoding from ANSI to Unicode which solved the problem. So now I have located the problem. Next how to sove it with vba when doing a mailmerge. Alternatively I can export my files using unicode encoding, but I dont know if its possible.. "Peter Jamieson" wrote: That would not surprise me if the encoding was different (e.g. one is encoded using Unicode and the other using Windows/ANSI). You can test some of that by opening the file in Notepad and saving it using the different encodings Notepad supports - or you can open in Word and save as encoded text. Peter Jamieson "bilisa" wrote in message ... The strange thing sbout it is that I have two .csv data files both containing ø,æ,å etc. and have the same structure, but they behave differently when merged with the same document!?!?! "Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,å, Å. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
#15
|
|||
|
|||
Thank you Peter
"Peter Jamieson" wrote: What I meant was that even if your data source is a Unicode Text file, you may not avoid the encoding dialog that pops up when you open a file. However, if you save as a Word document then use that as a data source, I think you will be OK - if the data source is large, just be prepared for a slow start to the merge. Some sample conversion macros... Sub ConvertToUTF8() ' convert to a UTF8 format text file ' Needs error checking etc. Dim oDoc as Word.Document ' change msoEncodingWestern to be the encoding you need. I think this should work. Set oDoc = Documents.Open("the path name of the file you need to convert.txt", _ False, , False, , , , , , _ wdOpenFormatEncodedText, _ msoEncodingWestern, _ False, False, , True) ' Several of the parameters here are optional or ' irrelevant - you can probably remove the lines from ' ReadOnlyRecommended to SaveAsAOCLetter oDoc.SaveAs _ FileName:="the path name of the file to convert to.txt", _ FileFormat:=wdFormatUnicodeTexÂ*t, _ AddToRecentFiles:=False, _ ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=FalseÂ*, _ SaveFormsData:=False, _ SaveAsAOCLetter:=False, _ Encoding:=msoEncodingUTF8, _ InsertLineBreaks:=False, _ AllowSubstitutions:=False, _ LineEnding:=wdCRLF oDoc.Close Savechanges:=False Set oDoc = Nothing End Sub or Sub ConvertToWord() ' convert to a Word document file ' Needs error checking etc. Dim oDoc as Word.Document ' change msoEncodingWestern to be the encoding you need. I think this should work. Set oDoc = Documents.Open("the path name of the file you need to convert.txt", _ False, , False, , , , , , _ wdOpenFormatEncodedText, _ msoEncodingWestern, _ False, False, , True) ' Several of the parameters here are optional or ' irrelevant - you can probably remove the lines from ' ReadOnlyRecommended to Encoding oDoc.SaveAs _ FileName:="the path name of the file to convert to.doc", _ FileFormat:=wdFormatDocument, _ AddToRecentFiles:=False, _ ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=FalseÂ*, _ SaveFormsData:=False, _ SaveAsAOCLetter:=False, _ Encoding:=msoEncodingUTF8, _ InsertLineBreaks:=False, _ AllowSubstitutions:=False, _ LineEnding:=wdCRLF oDoc.Close Savechanges:=False Set oDoc = Nothing End Sub Peter Jamieson "bilisa" wrote in message ... Maybe I can open my file (during mailmerge) and save it with the proper encoding.. Something like this: Documents.Open FileName:=filnavn, _ Encoding:="Unicode" Documents.Save Documents.Close "Peter Jamieson" wrote: If you use Unicode I don't think the ODBC approach will work properly, BTW. But I'm not completely sure. Peter Jamieson "bilisa" wrote in message ... I changed the encoding from ANSI to Unicode which solved the problem. So now I have located the problem. Next how to sove it with vba when doing a mailmerge. Alternatively I can export my files using unicode encoding, but I dont know if its possible.. "Peter Jamieson" wrote: That would not surprise me if the encoding was different (e.g. one is encoded using Unicode and the other using Windows/ANSI). You can test some of that by opening the file in Notepad and saving it using the different encodings Notepad supports - or you can open in Word and save as encoded text. Peter Jamieson "bilisa" wrote in message ... The strange thing sbout it is that I have two .csv data files both containing ø,æ,Ã¥ etc. and have the same structure, but they behave differently when merged with the same document!?!?! "Peter Jamieson" wrote: Sorry, my mistake. I still think it can be done, but right now I can only check with Word 2003, which sometimes behaves in a slightly different way. Apologies in advance if neither of these suggestions work: ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn, _ SubType:=wdMergeSubTypeOther or perhaps just ActiveDocument.MailMerge.OpenDataSource Name:="", _ Connection:="DSN=Delimited Text Files;DBQ=C:\;DriverId=27;FIL=text;MaxBufferSize=2 048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn It is certainly a conversion problem, but a. if you try to open the file as a "text file" (you can see a bit more of what is going on if you check Word Tools|Options|General|Confirm conversion at open before opening the file manually) you will probably see the oriental characters or a dialog asking about the character set b. if you try to use OLEDB, usually you see a dialog asking for the text (field) delimiter, and you may also see a character encoding dialog Peter Jamieson "bilisa" wrote in message news I followed your instructions, but I still have the same problem. It seems to me that this is some sort of conversion problem. Any ideas? "bilisa" wrote: This may sound as a stupid question: What is Text Driver DSN on system? "Peter Jamieson" wrote: I suggest you try the following instead, but use the pathname of the folder containing your text file instead of "c:\myfiles", and if necessary, change the name of the ODBC DSN in the connection parameter to match the name of a Text Driver DSN on your system. .OpenDataSource _ Name:=filnavn, _ Connection:="DSN=Delimited Text Files;DBQ=c:\myfiles;DriverId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM " & filnavn Peter Jamieson "bilisa" wrote in message ... Hi Im having problems when I merge my document / template with a .csv data source. My data source is already attached to the template via some vba script. I have some translation problems when the data posts contain danish letters as Ø,ø,æ,Æ,Ã¥, Ã…. Some times they disappear and sometimes they turn into asian symbols in the merged letter. They open correctly in Excel but are not displayed correctly in the merged letter. This is my code: Dim myheader As String filnavn = "C:\FLETFIL.CSV" With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=filnavn, _ Connection:="Entire Spreadsheet", _ SubType:=wdMergeSubTypeWord2000 ' Do it .Destination = wdSendToNewDocument .Execute End With What is wrong with it? Any help is appreciated. Yours sincerely |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need foreign alphabet letters | Microsoft Word Help | |||
Query a mail merge for multiple letters at once? | Mailmerge | |||
caps stuck on & all text highlighted when a few letters selected | New Users | |||
Mailmerge with multipule letters | Mailmerge | |||
Mail Merge is creating blank pages between form letters | Mailmerge |