TomGuy
03-12-2003, 02:11 PM
Hi,
I'm using VB6 to populate an Excel file that I've created. The Excel file has a few controls on it, including some checkboxes. This is the code I'm using to populate the checkboxes:
Dim Index As Integer
Index = 1
Dim obExcelApp As Excel.Application
Dim obWorkBook As Excel.Workbook
Set obExcelApp = CreateObject("Excel.Application")
Set obWorkBook = obExcelApp.Workbooks.Open("C:\WINDOWS\SYSTEM\Sales Order Template.xlt")
obWorkBook.Worksheets(Index).chkCheque.Value = True
' Save as a temporary file to save the template and show the temp file
obWorkBook.SaveAs ("C:\tempsales.xls")
obExcelApp.Visible = True
' clear the variables
Set obWorkBook = Nothing
Set obExcelApp = Nothing
When the excel file opens though, the checkboxes don't visually appear to be checked. They are checked, however, if I messagebox their values. Also, once the form is open, the first time that I try to check (enable) them, they flash checked but remain unchecked. After that they work normally (going from checked to unchecked)....It's as if the form is not being refreshed when it first loads.
If you can help me out, it would be greatly appreciated.
Thanks a bunch,
Tom
I'm using VB6 to populate an Excel file that I've created. The Excel file has a few controls on it, including some checkboxes. This is the code I'm using to populate the checkboxes:
Dim Index As Integer
Index = 1
Dim obExcelApp As Excel.Application
Dim obWorkBook As Excel.Workbook
Set obExcelApp = CreateObject("Excel.Application")
Set obWorkBook = obExcelApp.Workbooks.Open("C:\WINDOWS\SYSTEM\Sales Order Template.xlt")
obWorkBook.Worksheets(Index).chkCheque.Value = True
' Save as a temporary file to save the template and show the temp file
obWorkBook.SaveAs ("C:\tempsales.xls")
obExcelApp.Visible = True
' clear the variables
Set obWorkBook = Nothing
Set obExcelApp = Nothing
When the excel file opens though, the checkboxes don't visually appear to be checked. They are checked, however, if I messagebox their values. Also, once the form is open, the first time that I try to check (enable) them, they flash checked but remain unchecked. After that they work normally (going from checked to unchecked)....It's as if the form is not being refreshed when it first loads.
If you can help me out, it would be greatly appreciated.
Thanks a bunch,
Tom