Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date format
Hi,
how can I know what the default date and time format is set on the user's computer. Now I set it to a special format (yy-mm-dd) but the user asks to let it be like his computer's setting. Thanks Jos Vens |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date format
If you just put a date in an unformatted cell, it should use the default
date activecell.Value = Date ? activeCell.NumberFormat m/d/yy ActiveCell.Offset(1,0).Value = Time ? activeCell.Offset(1,0).Numberformat h:mm:ss AM/PM -- Regards, Tom Ogilvy "Jos Vens" wrote in message ... Hi, how can I know what the default date and time format is set on the user's computer. Now I set it to a special format (yy-mm-dd) but the user asks to let it be like his computer's setting. Thanks Jos Vens |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date format
Thanks Tom,
but: if i use your code, I get 05-10-29 in my cell (my systemsetting is jj-MM-dd) but ?activecell.numberformat gives me "m/d/yyyy", which is not my systemsetting. Can you still help me? Jos "Tom Ogilvy" schreef in bericht ... If you just put a date in an unformatted cell, it should use the default date activecell.Value = Date ? activeCell.NumberFormat m/d/yy ActiveCell.Offset(1,0).Value = Time ? activeCell.Offset(1,0).Numberformat h:mm:ss AM/PM -- Regards, Tom Ogilvy "Jos Vens" wrote in message ... Hi, how can I know what the default date and time format is set on the user's computer. Now I set it to a special format (yy-mm-dd) but the user asks to let it be like his computer's setting. Thanks Jos Vens |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date format
Jens,
Try NumberFormatLocal instead. -- HTH RP (remove nothere from the email address if mailing direct) "Jos Vens" wrote in message ... Thanks Tom, but: if i use your code, I get 05-10-29 in my cell (my systemsetting is jj-MM-dd) but ?activecell.numberformat gives me "m/d/yyyy", which is not my systemsetting. Can you still help me? Jos "Tom Ogilvy" schreef in bericht ... If you just put a date in an unformatted cell, it should use the default date activecell.Value = Date ? activeCell.NumberFormat m/d/yy ActiveCell.Offset(1,0).Value = Time ? activeCell.Offset(1,0).Numberformat h:mm:ss AM/PM -- Regards, Tom Ogilvy "Jos Vens" wrote in message ... Hi, how can I know what the default date and time format is set on the user's computer. Now I set it to a special format (yy-mm-dd) but the user asks to let it be like his computer's setting. Thanks Jos Vens |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date format
Jos,
Apologies for the wrong name, I was watching Jens Lehmann on the TV Bob "Bob Phillips" wrote in message ... Jens, Try NumberFormatLocal instead. -- HTH RP (remove nothere from the email address if mailing direct) "Jos Vens" wrote in message ... Thanks Tom, but: if i use your code, I get 05-10-29 in my cell (my systemsetting is jj-MM-dd) but ?activecell.numberformat gives me "m/d/yyyy", which is not my systemsetting. Can you still help me? Jos "Tom Ogilvy" schreef in bericht ... If you just put a date in an unformatted cell, it should use the default date activecell.Value = Date ? activeCell.NumberFormat m/d/yy ActiveCell.Offset(1,0).Value = Time ? activeCell.Offset(1,0).Numberformat h:mm:ss AM/PM -- Regards, Tom Ogilvy "Jos Vens" wrote in message ... Hi, how can I know what the default date and time format is set on the user's computer. Now I set it to a special format (yy-mm-dd) but the user asks to let it be like his computer's setting. Thanks Jos Vens |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date format
Hi Jens,
Try: '================= Function SettingVaL(strSetting As String) Dim strComputer As String Dim strKeyPath As String Dim strEntryName As Variant Dim strValue As String Dim strLogFile As String Dim objReg As Object Dim objFSO As Object Dim arrValue, byteValue, arrEntryNames, arrValueTypes Const HKEY_USERS = &H80000003 Const HKEY_CURRENT_USER = &H80000001 Const REG_SZ = 1 Const REG_EXPAND_SZ = 2 Const REG_BINARY = 3 Const REG_DWORD = 4 Const REG_MULTI_SZ = 7 strKeyPath = ".DEFAULT\Control Panel\International" strLogFile = "C:\RegionalSettings.txt" Set objFSO = CreateObject("Scripting.FileSystemObject") ''Set objLogFile = objFSO.CreateTextFile(strLogFile) '''objLogFile.Writeline ("This logfile was made on " _ & Date & " at " & Time & "." & VbCrLf ) strComputer = "." ' Connect to the WMI Regisitry-provider Set objReg = GetObject("winmgmts:{impersonationLevel" _ & "=impersonate}!\\" & strComputer _ & "\root\default:StdRegProv") objReg.EnumValues HKEY_USERS, strKeyPath, _ arrEntryNames, arrValueTypes For Each strEntryName In arrEntryNames '*** This is the only Binary value If strEntryName = "DefaultBlindDialFlag" Then objReg.GetBinaryValue HKEY_USERS, strKeyPath, _ strEntryName, arrValue For Each byteValue In arrValue If strEntryName = "s" & strSetting Then SettingVaL = strValue Exit Function End If Next Else '*** These are all RegSZ value's objReg.GetStringValue HKEY_USERS, strKeyPath, _ strEntryName, strValue If strEntryName = "s" & strSetting Then SettingVaL = strValue Exit Function End If End If Next End Function '<<================= '================= Sub GetDateFormat() Dim ShortDt As String Dim LongDt As String ShortDt = SettingVaL("ShortDate") LongDt = SettingVaL("LongDate") MsgBox ShortDt & vbNewLine & LongDt End Sub '<<================= --- Regards, Norman "Jos Vens" wrote in message ... Thanks Tom, but: if i use your code, I get 05-10-29 in my cell (my systemsetting is jj-MM-dd) but ?activecell.numberformat gives me "m/d/yyyy", which is not my systemsetting. Can you still help me? Jos "Tom Ogilvy" schreef in bericht ... If you just put a date in an unformatted cell, it should use the default date activecell.Value = Date ? activeCell.NumberFormat m/d/yy ActiveCell.Offset(1,0).Value = Time ? activeCell.Offset(1,0).Numberformat h:mm:ss AM/PM -- Regards, Tom Ogilvy "Jos Vens" wrote in message ... Hi, how can I know what the default date and time format is set on the user's computer. Now I set it to a special format (yy-mm-dd) but the user asks to let it be like his computer's setting. Thanks Jos Vens |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date format
Thanks Bob,
it is really what I'm looking for Thanks Norman for your code I may use later maybe, Greetings Jos "Bob Phillips" schreef in bericht ... Jens, Try NumberFormatLocal instead. -- HTH RP (remove nothere from the email address if mailing direct) "Jos Vens" wrote in message ... Thanks Tom, but: if i use your code, I get 05-10-29 in my cell (my systemsetting is jj-MM-dd) but ?activecell.numberformat gives me "m/d/yyyy", which is not my systemsetting. Can you still help me? Jos "Tom Ogilvy" schreef in bericht ... If you just put a date in an unformatted cell, it should use the default date activecell.Value = Date ? activeCell.NumberFormat m/d/yy ActiveCell.Offset(1,0).Value = Time ? activeCell.Offset(1,0).Numberformat h:mm:ss AM/PM -- Regards, Tom Ogilvy "Jos Vens" wrote in message ... Hi, how can I know what the default date and time format is set on the user's computer. Now I set it to a special format (yy-mm-dd) but the user asks to let it be like his computer's setting. Thanks Jos Vens |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
permanent conversion of 1904 date format to 1900 date format | Excel Worksheet Functions | |||
How do I convert dd/mm/yy date format to yyddd Julian date format | Excel Worksheet Functions | |||
Convert date + time text format to date format | Excel Worksheet Functions | |||
code to convert date from TEXT format (03-02) to DATE format (200203) | Excel Programming | |||
Change a date in text format xx.xx.20xx to a recognised date format | Excel Programming |