ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GetLocaleInfo Automation Error (https://www.excelbanter.com/excel-programming/427297-getlocaleinfo-automation-error.html)

jean grey

GetLocaleInfo Automation Error
 
Hi everyone. In this code, when it reaches the line GetLocaleInfo, it displays

Run-time error '2147417848' Automation Error The object invoked has
disconnected from its clients.

Could somebody please tell me what's wrong?
I'm using WinXP, MS Excel 2003.
Thanks in advance!


Private Const LOCALE_SSHORTDATE As Long = &H1F

Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long

Private Declare Function GetLocaleInfo Lib "kernel32" _
Alias "GetLocaleInfoA" _
(ByVal Locale As Long, _
ByVal LCType As Long, _
lpLCData As String, _
ByVal cchData As Long) As Long

Private Sub GetInfo

Dim lcid As Long

lcid = GetSystemDefaultLCID()

Dim format As String

Dim temp As Long

temp = GetLocaleInfo(lcid, LOCALE_SSHORTDATE, format, 256)

End Sub


jean grey

GetLocaleInfo Automation Error
 
I know now where the prob was. I forgot to put ByVal in lpLCData parameter.

"jean grey" wrote:

Hi everyone. In this code, when it reaches the line GetLocaleInfo, it displays

Run-time error '2147417848' Automation Error The object invoked has
disconnected from its clients.

Could somebody please tell me what's wrong?
I'm using WinXP, MS Excel 2003.
Thanks in advance!


Private Const LOCALE_SSHORTDATE As Long = &H1F

Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long

Private Declare Function GetLocaleInfo Lib "kernel32" _
Alias "GetLocaleInfoA" _
(ByVal Locale As Long, _
ByVal LCType As Long, _
lpLCData As String, _
ByVal cchData As Long) As Long

Private Sub GetInfo

Dim lcid As Long

lcid = GetSystemDefaultLCID()

Dim format As String

Dim temp As Long

temp = GetLocaleInfo(lcid, LOCALE_SSHORTDATE, format, 256)

End Sub



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com