Hi All,

Can someone help me with starting excel, change the locale settings in excel and then open an excel file (and turn on autofilters and autofit all columns).

As I am in Australia, I would like my dates in my excel file in my format dd/mm/yyyy. I have looked and looked and even tried a vb app... When the file opens some dates are corrupted, especially if there is a leading zero or the month and day are less than 12... I believe I need to enforce the locale or regional settings somehow...

Here is my code:

 Code:
;------------------------------------------------------------------------------
;   Name:       excel.kix
;------------------------------------------------------------------------------

break on
$=setoption('Explicit','ON')
$=setoption('WrapAtEOL','ON')
$=setoption('NoVarsInStrings','ON')

main
Quit 0

;------------------------------------------------------------------------------

Function main()
  Dim $rc
  Dim $filename
  Dim $autofilters
  Dim $xl
  Dim $wb
  Dim $ws
  Dim $rng

  $filename = "c:\fred.xls"
  $autofilters = "Y"

  ; Start excel.
  $xl = CreateObject("Excel.Application")
  if @error
    messagebox ("Errors detected starting excel...", "Unable to run command.", 0, 5)
    quit 1
  endif

  $xl.Visible = True
  $xl.DisplayAlerts = 0

  if exist($filename)			; if the file exists, open it

    $wb = $xl.Workbooks.Open($filename)
    $ws = $wb.WorkSheets(1)

    $rng = $ws.Range("A1:CC2000")

    if $autofilters = "Y"
      $rng.Rows("1:1").Select
      $rng.AutoFilter
      $ws.Range("A2").Select
    endif

    $rng.Cells.Select
    $rng.Cells.EntireColumn.AutoFit
    $ws.Range("A1").Select

  endif

  exit @ERROR

EndFunction

;------------------------------------------------------------------------------



Any help will be greatly appreciated.
_________________________
Regards,
Andy.


--Just shoot me, please.--