Changing date format in Windows Regional Settings from VBA?

channers

New Member
Joined
Apr 5, 2005
Messages
24
Hi,

First of all, many thanks for all the posts on this great forum. I tried VBA for the first time six months ago and I've never looked back since. The forum has provided so many solutions/ideas without frequently having to post. I really have learnt so many new things :)

I do, however, have to rack your brains for one thing...does anyone know how to change the locale in Control Panel...Regional Settings directly from VBA? The majority of the systems at work are configured to United States instead of United Kingdom and this poses a problem for the date format in the tool I've written. I'd really like to have the macro change the settings automatically rather than ask the user to do so manually. Is there any way this is possible?

I've seen the following code in a post to change the decimal from . to , and back:

Code:
Private Declare Function SetLocaleInfo _ 
  Lib "kernel32" Alias "SetLocaleInfoA" ( _ 
  ByVal Locale As Long, _ 
  ByVal LCType As Long, _ 
  ByVal lpLCData As String) As Boolean 

Private Declare Function GetUserDefaultLCID% Lib "kernel32" () 

Private Const LOCALE_SDECIMAL = &HE 

Private Sub ChangeSettingExample() 
'change the setting of the character displayed as the decimal separator. 
    Call SetLocalSetting(LOCALE_SDECIMAL, ",") 'to change to "," 
    'check your control panel to verify or use the 
    'GetLocaleInfo API function 
    Stop 
    Call SetLocalSetting(LOCALE_SDECIMAL, ".") 'to back change to "." 
End Sub 

Private Function SetLocalSetting(LC_CONST As Long, Setting As String) As Boolean 
    Call SetLocaleInfo(GetUserDefaultLCID(), LC_CONST, Setting) 
End Function

But, does anybody know the code to change the whole locale to UK? Or at least the code to change the date to dd/mm/yyyy for vbShortDate?

Many thanks and best regards,

Jules
 
Hi !

Did you get a chance to get some type of code for this issue?
 
Upvote 0
Welcome to the MrExcel board!

Did you realise that you are asking in thread that is nearly 16 years old!?
Also, the OP has not been on the forum since 2009 so fairly unlikely they will reply.

Might be worth starting your own new thread to ensure fresh eyes are looking at your question.
 
Upvote 0
Welcome to the MrExcel board!

Did you realise that you are asking in thread that is nearly 16 years old!?
Also, the OP has not been on the forum since 2009 so fairly unlikely they will reply.

Might be worth starting your own new thread to ensure fresh eyes are looking at your question.

I wasn't expecting for a answer from the OP, thought I would revive the post.
 
Upvote 0
Welcome to the MrExcel board!

Did you realise that you are asking in thread that is nearly 16 years old!?
Also, the OP has not been on the forum since 2009 so fairly unlikely they will reply.

Might be worth starting your own new thread to ensure fresh eyes are looking at your question.
And also, thank you for the great welcome :D
 
Upvote 0
I wasn't expecting for a answer from the OP, thought I would revive the post.
Fair enough, but I think a lot of potential helpers will bypass the thread without looking because it has several replies. A fresh thread by you with no replies will likely attract many more viewers, particularly from those helpers that use the 'Unanswered threads' link at the top of the forum as their starting point for helping when they log on.
You can always include a link to this thread if you think that is relevant.
 
Upvote 0
Fair enough, but I think a lot of potential helpers will bypass the thread without looking because it has several replies. A fresh thread by you with no replies will likely attract many more viewers, particularly from those helpers that use the 'Unanswered threads' link at the top of the forum as their starting point for helping when they log on.
You can always include a link to this thread if you think that is relevant.
ok, will start a new thread then, thank you for the help.
 
Upvote 0

Forum statistics

Threads
1,226,835
Messages
6,193,225
Members
453,781
Latest member
Buzby

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