Link to home
Start Free TrialLog in
Avatar of SindhujaCheema
SindhujaCheema

asked on

Saving Excel automatically.

Hi
1) How can I save excel directly in the following peice of code?
 Open "test.xls" For Output As #ff
     ' make changes
  Close #ff

2) On another form I save changes using wb.save and unload the form.
For example I have deleted a particular row and then i save changes.
Then when i load the form again and search for the deleted row, it still appears.
It is not refereshed.
How can I refresh my excelsheet, such that, after I delete and rerun a query, I donot see it.

Thanks a lot.

Regards
Avatar of jimbobmcgee
jimbobmcgee
Flag of United Kingdom of Great Britain and Northern Ireland image

How are you making your changes to the Excel Sheet?  The .XLS sheet file, in flat text form looks decidedly full of garbage characters.  

Are you, perhaps, working with .CSV files?  If not, perhaps you should consider those, as they will read far more easily into a VB app, with Open/Close #ff ...
ASKER CERTIFIED SOLUTION
Avatar of jimbobmcgee
jimbobmcgee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SindhujaCheema
SindhujaCheema

ASKER

1)
I was using a .xls sheet.
i changed it to a .csv extention and i dont have the garbage anymore.
thank you.
However...
Everytime i get a promt(messagebox) from excel asking me if i want to save changes made.
I dont want this promt.
I want to save it automatically before i close the excel sheet.


2)
Ìs there a possibility to see the changes without loading and unloading the form.

Like mentioned i was using Show. After I load the form I can see the changes.
However I dont want to open and close this window enerytime.
Can i delete a line and also view the changes without loading the form?
I am opening the workbook each time, save and closing it.

So with one button I delete and with other button i view changes made

Thank ypu
Solution:
2) reset all return variables from excel.

Please help me with 1)
thanks!
Are you writing your code in Excel/VBA or in VB6?  
If you are writing in Excel/VBA you can probably use a ThisWorkBook.Save function to save the changes to the sheet.

If you are using an Excel object within VB6, you should use its Save function...