Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Modify windows language from VBA Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex St-Pierre - 25 Jan 2007 16:29 GMT
Hi,
I have a program that modify the windows language inside Excel.
Call ExecCmd("rundll32.exe shell32.dll,Control_RunDLL intl.cpl" + ",,5")
When I execute this command, the language inside the control panel is
changed but the number displayed in Excel still show the old language. If I
open the control panel and change it manually (should gives same result), the
number displayed in Excel show the new language. Does anyone know why Excel
doesn't show the same result for both method ? It's like if there's a refresh
problem.
Thanks!
Alex

All codes:
  Private Type STARTUPINFO
     cb As Long
     lpReserved As String
     lpDesktop As String
     lpTitle As String
     dwX As Long
     dwY As Long
     dwXSize As Long
     dwYSize As Long
     dwXCountChars As Long
     dwYCountChars As Long
     dwFillAttribute As Long
     dwFlags As Long
     wShowWindow As Integer
     cbReserved2 As Integer
     lpReserved2 As Long
     hStdInput As Long
     hStdOutput As Long
     hStdError As Long
  End Type

  Private Type PROCESS_INFORMATION
     hProcess As Long
     hThread As Long
     dwProcessID As Long
     dwThreadID As Long
  End Type

  Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
     hHandle As Long, ByVal dwMilliseconds As Long) As Long

  Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
     lpApplicationName As String, ByVal lpCommandLine As String, ByVal _
     lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
     ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
     ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, _
     lpStartupInfo As STARTUPINFO, lpProcessInformation As _
     PROCESS_INFORMATION) As Long

  Private Declare Function CloseHandle Lib "kernel32" _
     (ByVal hObject As Long) As Long

  Private Declare Function GetExitCodeProcess Lib "kernel32" _
     (ByVal hProcess As Long, lpExitCode As Long) As Long

  Private Const NORMAL_PRIORITY_CLASS = &H20&
  Private Const INFINITE = -1&

  Public Function ExecCmd(cmdline$)
     Dim proc As PROCESS_INFORMATION
     Dim start As STARTUPINFO

     ' Initialize the STARTUPINFO structure:
     start.cb = Len(start)

     ' Start the shelled application:
     Ret& = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
        NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)

     ' Wait for the shelled application to finish:
        Ret& = WaitForSingleObject(proc.hProcess, INFINITE)
        Call GetExitCodeProcess(proc.hProcess, Ret&)
        Call CloseHandle(proc.hThread)
        Call CloseHandle(proc.hProcess)
        ExecCmd = Ret&
  End Function

  Sub Form_Click()

     Dim retval As Long
   'retval = ExecCmd("notepad.exe")
     retval = ExecCmd("rundll32.exe shell32.dll,Control_RunDLL intl.cpl" +
",,5")
     MsgBox "Process Finished, Exit Code " & retval
  End Sub

Signature

Alex St-Pierre

Perry - 25 Jan 2007 23:49 GMT
I'm so terribly sorry but:
This is a Microsoft Word (the document editing program....) newsgroup.
Are you aware of that ?

Pls take note in where y're sending yr questions/

Krgrds,
Perry

> Hi,
> I have a program that modify the windows language inside Excel.
[quoted text clipped - 88 lines]
>      MsgBox "Process Finished, Exit Code " & retval
>   End Sub
Alex St-Pierre - 26 Jan 2007 00:48 GMT
Sorry, I'll post it in the excel group.
Thanks!
Alex
Signature

Alex St-Pierre

> I'm so terribly sorry but:
> This is a Microsoft Word (the document editing program....) newsgroup.
[quoted text clipped - 97 lines]
> >      MsgBox "Process Finished, Exit Code " & retval
> >   End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.