MS Access RetVal Command

santa12345

Board Regular
Joined
Dec 2, 2020
Messages
66
Office Version
  1. 365
Platform
  1. Windows
Hello.
I currently have some vb code in Access that is working.
The code looks at a table in access. Lets say it has 400 line items of information.
The script will take the first record, run a few queries, export each table to an excel file (template). Let's say the template is called test.xls
So the queries are ran, tables are exported into various tabs within test.xls and using the following command, it saves the files with some variables. (date/region,etc...)

RetVal = Shell("cmd /c copy /y c:\123\test.xls c:\123\US\" & datename & "\" & strDistrict & "\" & strWI & txt_agree & "\" & strWI & txt_agree & strxcel, vbHide)

The process keeps looping thru the 400 line item table, and repeats. Everything is working, the only issue I have is the template grows in size after repeating this process.
If i simply open up the template, save it, close it, the file size decreases considerable.

I was wondering if there was a Retval command or some other line item command - that I can add after the above command.....that will open the template (if needed), save and close it.

Any input would be greatly appreciated.
 
Thats a good idea.
I will try to incorporate that into the current VB and let you know.
Thanks!
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I think I am good to go with your suggestion. Thank you for replying and providing valuable input!!!!
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top