Excel language breaks VBA macro

alfranco17

Board Regular
Joined
Apr 14, 2013
Messages
198
Hi.

I have a macro enabled workbook in a shared folder. It is used by three people. One has Excel in English, the other two have Excel in Spanish.

To use Special Paste - Text in Spanish, the format is "Texto", in English, it is "Unicode Text".

I decided to try to do it both ways with an "On Error Resume Next" and expect one of them to fail.

VBA Code:
    On Error Resume Next
    ActiveSheet.PasteSpecial Format:="Texto"
    ActiveSheet.PasteSpecial Format:="Unicode Text"
    On Error GoTo 0

Is there a more elegant solution? Like using a number instead of a string for format?

Thanks.
Armando.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
If you know it is always going to be one of those two choices, that actually does not seem to be a bad way to do it. Another alternative might be to add code to detect which flavor of Excel, perhaps by reading a registry setting (like the codepage for example), is calling the macro. I'm not sure it's worth the effort if what you have is working.
 
Upvote 0
If you know it is always going to be one of those two choices, that actually does not seem to be a bad way to do it. Another alternative might be to add code to detect which flavor of Excel, perhaps by reading a registry setting (like the codepage for example), is calling the macro. I'm not sure it's worth the effort if what you have is working.
Thanks. I tried that approach once. There were too many codepages for English and Spanish.
 
Upvote 0
Hi,​
as just using the VBA property International you can find for example the country code, to see on VBA help …​
 
Upvote 0
Another VBA help must see : LanguageSettings.LanguageID …​
 
Upvote 0
Try Format:=1. The options you get when doing it manually can be converted to numbers using the order they appear in the dialog, starting at 0, not 1.
 
Upvote 0
Solution
Another VBA help must see : LanguageSettings.LanguageID …​
Thank you. It's a very interesting property. Application.LanguageSettings.LanguageID(msoLanguageIDUI) has 20 different Spanish variants. RoryA's answer is the one I was looking for, but this one is very interesting.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,180
Members
448,871
Latest member
hengshankouniuniu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top