mikoamberg
New Member
- Joined
- Apr 12, 2008
- Messages
- 2
Hi everyone,
I am new to this forum so I would like to thank you for considering my threat.
<o></o>
I have a problem with creating a VBA code for a macro fitting my requirements. I would like the macro to create an .htm file based on cell values in an opened Excell spreadsheet. For the content of the file I would like the macro to use the data in cells J2 and J3 and I would like to name the file according to cell J1. Actually I would like to create multiple htm files, but I guess (I hope) the loop will be the minor problem. Now, I have a very nice code, which does all these things – however since my htm files will include Slavic characters they are displayed badly in the resulting file. Here the code (I am not a VBA expert, so I took this code from a nice page and transformed it, probably i left some unnecessary data):<o></o>
<o> </o>
Sub MakeHTM_Basic()<o></o>
' Defining a list of variables used in this program<o></o>
Dim PageName As String<o></o>
<o> </o>
codepart1 = Range("j2").Value<o></o>
codepart2 = Range("j3").Value<o></o>
fName = Range("j1").Value<o></o>
PageName = "C:\" & fName & ".htm" 'location and name of saved file<o></o>
MyPageTitle = Range("A1").Value<o></o>
<o> </o>
Open PageName For Output As #1<o></o>
<o> </o>
Print #1, codepart1<o></o>
Print #1, codepart2<o></o>
Close #1<o></o>
<o> </o>
End Sub
You can see the problem and check the result when you place the following text into cell J2:
ą
and the following text to cell J3:
Ś
(The value in J1 can be: test)
<o></o>
<o> </o>
So what I would like is to make the macro save the resulting htm file in unicode and not in ansii as it obviousy does. I fought fiercly with it, replaced my notpad for other text editors but nothing helped yet. I am not sure if notepad is the source of the problem or if it is the VBA editor. Has anyone an idea how to make this work? This would help me a lot.<o></o>
<o> </o>
Thank you very much and have a good day!<o></o>
I am new to this forum so I would like to thank you for considering my threat.
<o></o>
I have a problem with creating a VBA code for a macro fitting my requirements. I would like the macro to create an .htm file based on cell values in an opened Excell spreadsheet. For the content of the file I would like the macro to use the data in cells J2 and J3 and I would like to name the file according to cell J1. Actually I would like to create multiple htm files, but I guess (I hope) the loop will be the minor problem. Now, I have a very nice code, which does all these things – however since my htm files will include Slavic characters they are displayed badly in the resulting file. Here the code (I am not a VBA expert, so I took this code from a nice page and transformed it, probably i left some unnecessary data):<o></o>
<o> </o>
Sub MakeHTM_Basic()<o></o>
' Defining a list of variables used in this program<o></o>
Dim PageName As String<o></o>
<o> </o>
codepart1 = Range("j2").Value<o></o>
codepart2 = Range("j3").Value<o></o>
fName = Range("j1").Value<o></o>
PageName = "C:\" & fName & ".htm" 'location and name of saved file<o></o>
MyPageTitle = Range("A1").Value<o></o>
<o> </o>
Open PageName For Output As #1<o></o>
<o> </o>
Print #1, codepart1<o></o>
Print #1, codepart2<o></o>
Close #1<o></o>
<o> </o>
End Sub
You can see the problem and check the result when you place the following text into cell J2:
ą
and the following text to cell J3:
Ś
(The value in J1 can be: test)
<o></o>
<o> </o>
So what I would like is to make the macro save the resulting htm file in unicode and not in ansii as it obviousy does. I fought fiercly with it, replaced my notpad for other text editors but nothing helped yet. I am not sure if notepad is the source of the problem or if it is the VBA editor. Has anyone an idea how to make this work? This would help me a lot.<o></o>
<o> </o>
Thank you very much and have a good day!<o></o>