Data not going into Excel from Form button - Do I need a thread

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have created a Windows Form that takes input. When the Run button is
pressed the form is disabled and the code checks some files and inputs the
data into an Excel worksheet (that is hidden so that I cannot watch as it
gets filled up). When it is done it saves the Excel file.

I find that if I go into another program while it's trying to work on the
Excel spreadsheet that not all of the data appears (missing data!). If I
click the Run button and then do nothing (don't touch the keyboard) all of
the data appears in the spreadsheet no problem.

What the heck am I missing??? I don't have the Minimize and Maximize
buttons on the Windows Form but that should not make a difference right? Do
I need to make a thread or something?
 
I find that if I go into another program while it's trying to work on the
Excel spreadsheet that not all of the data appears (missing data!). If I
click the Run button and then do nothing (don't touch the keyboard) all of
the data appears in the spreadsheet no problem.

Are you using another program to access the Excel spreadsheet as your
program is writing information to it? If this is the case there is probably
a lock on the file by one of the applications; most likely your app is not
locking the file and when Excel opens it will lock it and no further data
can be written to it your program should error out. Is your program
crashing or reporting any errors?
 
If I don't touch the computer while it is processing it works fine. Once I
start to work with other programs it starts to drop the data from Excel. No
Errors or anything. I just think that when I do other work on the computer
the Excel workbook no longer has the focus.
 
Back
Top