PC Review


Reply
Thread Tools Rate Thread

2-byte characters: from VBA code to a worksheet; in MsgBox prompts

 
 
=?Utf-8?B?am8=?=
Guest
Posts: n/a
 
      23rd Oct 2007
Hi,
If filling cells from VBA code with a string containing 2-byte characters
(Central European), the result is corrupted characters in worksheet cells.
eg.

sheet1.cells(1,1).value = "č1ť2ď3ň4ľ5" results in è12ï3ò4¾5 in a cell

Related topic is using 2-byte characters in MsgBox prompts. If controls are
drawn in the VBA editor this can be prevented by setting appropriate script,
however I do not know how to do it with "common" msgboxes defined in a
simpliest way eg.
msgbox "č1ť2ď3ň4ľ5" or with dynamic captions of controls which seem to
overwrite the default script of respective control's caption.

Storing strings somewhere in cells and copying the values from cells to
cells does work but I hope there is some smoother way how to solve it.
Moreover this way does not work with msgbox prompts resp. it converts all
characters into 1-byte characters (in given example c1t2d3n4l5)

Thanks in advance for help
 
Reply With Quote
 
 
 
 
=?Utf-8?B?U21hbGx3ZWVk?=
Guest
Posts: n/a
 
      23rd Oct 2007
Looks like a solution is in the thread "Korean script compatibility with Vba"
- might be worth searching this forum for that.

"jo" wrote:

> Hi,
> If filling cells from VBA code with a string containing 2-byte characters
> (Central European), the result is corrupted characters in worksheet cells.
> eg.
>
> sheet1.cells(1,1).value = "č1ť2ď3ň4ľ5" results in è12ï3ò4¾5 in a cell
>
> Related topic is using 2-byte characters in MsgBox prompts. If controls are
> drawn in the VBA editor this can be prevented by setting appropriate script,
> however I do not know how to do it with "common" msgboxes defined in a
> simpliest way eg.
> msgbox "č1ť2ď3ň4ľ5" or with dynamic captions of controls which seem to
> overwrite the default script of respective control's caption.
>
> Storing strings somewhere in cells and copying the values from cells to
> cells does work but I hope there is some smoother way how to solve it.
> Moreover this way does not work with msgbox prompts resp. it converts all
> characters into 1-byte characters (in given example c1t2d3n4l5)
>
> Thanks in advance for help

 
Reply With Quote
 
=?Utf-8?B?am8=?=
Guest
Posts: n/a
 
      23rd Oct 2007
Thanks it really is, unfortunately I am not familiar with calling APIs. Tried
to find something about using APIs and downloaded the Win32API but feeling
lost in the topic...;-/
Found two "suspicious" APIs for solving MsgBox issue -
Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As
Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long)
As Long

and

Declare Function MessageBoxEx Lib "user32" Alias "MessageBoxExA" (ByVal hwnd
As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal uType As
Long, ByVal wLanguageId As Long) As Long

but not aware of the way to pick the correct one and use it.
Concerning the passing strings from VBA code into cells I don't even know,
what I should look for in Win32API...;-(

Grateful for any shortcut to the solution.

"Smallweed" wrote:

> Looks like a solution is in the thread "Korean script compatibility with Vba"
> - might be worth searching this forum for that.
>
> "jo" wrote:
>
> > Hi,
> > If filling cells from VBA code with a string containing 2-byte characters
> > (Central European), the result is corrupted characters in worksheet cells.
> > eg.
> >
> > sheet1.cells(1,1).value = "č1ť2ď3ň4ľ5" results in è12ï3ò4¾5 in a cell
> >
> > Related topic is using 2-byte characters in MsgBox prompts. If controls are
> > drawn in the VBA editor this can be prevented by setting appropriate script,
> > however I do not know how to do it with "common" msgboxes defined in a
> > simpliest way eg.
> > msgbox "č1ť2ď3ň4ľ5" or with dynamic captions of controls which seem to
> > overwrite the default script of respective control's caption.
> >
> > Storing strings somewhere in cells and copying the values from cells to
> > cells does work but I hope there is some smoother way how to solve it.
> > Moreover this way does not work with msgbox prompts resp. it converts all
> > characters into 1-byte characters (in given example c1t2d3n4l5)
> >
> > Thanks in advance for help

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Can you improve this code : Search Byte[] backwards for byte Pattern Family Tree Mike Microsoft C# .NET 0 26th Sep 2008 12:34 AM
msgbox prompts? jatman Microsoft Word Document Management 2 17th May 2008 04:45 AM
single byte characters ? how many bytes for 37 characters ? bitshift Microsoft C# .NET 4 5th Jul 2007 09:22 PM
VBA code to enter extended characters onto a worksheet =?Utf-8?B?UGV0ZXIgUm9vbmV5?= Microsoft Excel Programming 5 21st Jan 2005 10:14 AM
VBA code for MsgBox AND WorkSheet Active at same time Dennis Microsoft Excel Misc 2 1st Mar 2004 12:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 PM.