Solved

Saving Excel automatically.

Posted on 2004-09-29
5
224 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:SindhujaCheema
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12179597
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 ...
0
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 125 total points
ID: 12179686
As for your form:

Where you are unloading the form, you are also saving the workbook, with wb.save?  Are you also unloading the sheet?  Perhaps you should add, in your QueryUnload routine, the wb.save, a sheet unloading function (perhaps wb.close?) and then the form unload.

Then in your Load routine, reopen the workbook.

Incidently, are you loading/unloading your form, or showing/hiding your form?  I believe form1.show does not call Load if the form is already in memory...

I might be wrong, though...
0
 

Author Comment

by:SindhujaCheema
ID: 12179951
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
0
 

Author Comment

by:SindhujaCheema
ID: 12180937
Solution:
2) reset all return variables from excel.

Please help me with 1)
thanks!
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12184885
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...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now