Solved

Saving Excel automatically.

Posted on 2004-09-29
5
228 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
String manipulation in Visual Basic 7 71
Windows Script Host failed (Access is denied.) error 6 214
Problem to With line 4 63
Automatic Email Reminder 4 56
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

790 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