Can't get MACRO to delete excel file and print rest of excel files

549
0
02-22-2013 10:52 AM
DavidWilson4
New Contributor
Hello to the masters of programming!

I am noob to programming, but I have taken some visual basic progamming classes.

Anyway, I'll get straight to the point. 

I need to have MACRO print out muplite quant reports for multiple excel files without me manually deleting each one at a time.  I can get the first excel file to print, but I have to manually delete that file from a referenced folder before I click on the MACRO button again to run the program another time.  Meaning, how can I just press the "GO" button on MACRO once, and have it print out all the quant reports, and have it delete the files for me?  Or if it can't delete the files, that's fine.  When I press "GO" only the first print out is printed.  If I press "GO" again without deleting anything I will get the same print out.  So, how do I either delete the excel files with MACRO or how do I index the excel files so they will go from one to the next in the print outs?

Here is the script I have:

#
X="C:\QuickPCB"
temp="quickpcbs.xlt"
=DIRECTORY(X)
=SET.NAME("FAONE",FILES("front\*.xls"))
=IF(ISERROR(ROWS(FAONE)))
=ALERT("No files found in directory column1",2)
=ELSE()
=SET.NAME("FATW0",FILES("back\*.xls"))
=IF(ISERROR(ROWS(FATW0)))
=ALERT("No files found in directory column2",2)
=ELSE()
'ALERTS FOR UNEVEN NUMBER OF FILES
N=ROWS(FAONE)
M=ROWS(FATW0)
=IF(N=M)
=GOTO($B20$)
=END.IF()
=GOTO($B20$)
=ELSE
=ALERT("Problem with number of files in subdirecotries; the must be equal", 2)
=END.IF()
=RETURN()

'BEGINS INDEXING FILES
l=1
=FOR("l", 1,M,1)
cm=INDEX(FAONE,1)
chl=INDEX(FATW0,1)
chl=cm

=DIRECTORY(X)   
=DIRECOTRY("front")
=OPEN(cm)
=SELECT("R3C2:R8C8")
=CUT()
=ACTIVATE("quickpcbs.xlt")
=SELECT("R2C1:R7C7")
=PASTE()
=ACTIVATE(cm)
=SELECT("R9C1:R84C2")
=CUT()
=ACTIVATE("quickpcbs.xlt")
=SELECT("R1C18:R76C19")
=PASTE()
=ACTIVATE(cm)
=FILE.CLOSE(FLASE)
=DIRECTORY(X)
=DIRECTORY("black")
=OPEN(chl)
=SELECT("R3C2:R8C8")
=CUT()
=ACTIVATE("quickpcbs.xlt")
=SELECT("R2C10:R7C16")
=PASTE()
=ACTIVATE(chl)
=FILE.CLOSE(FALSE)
=ACTIVATE("quickpcbs.xlt")
=SELECT("R2C1:R23C7")
=SORT()
=SELECT("R2C10:R23C16")
=SORT()
=PRINT()
FAONE=FAONE+1
FATW0=FATW0+1
=NEXT()
=END.IF()
=END.IF()
=RETURN()
#

Please help me if you would like!

Thanks a bunch!

--David W.
dwilson.chem@gmail.com
0 Kudos
0 Replies