Solved

Saving Excel automatically.

Posted on 2004-09-29
5
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Suggested Courses
Course of the Month6 days, 7 hours left to enroll

636 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