Solved

Saving Excel automatically.

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 68
Vb.net 2008 2 59
How to make an ADE file by code? 11 87
fso.FolderExists("\\server\HiddenFolder$") 4 66
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

777 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