With the help of an expert (T.Willey) on The Swamp I was able to get a working batch script. Here is the final result.
;This program creates a batch process for IO drawings. It starts by creating the IO drawings then runs 2 commands.
;Command 1, sets up the drawing and adds it to the active project. Command 2, inserts the IO for that drawing.
;Need in conjuntion with this program: tb_concatenate.lsp, match_proj_properties.lsp, Insert IO.lsp, GetExcel.lsp,
;KillExcel.vbs
;Created March 11, 2010
;Debbie Guenthner
; ; ;;;; ;;;;; ;; ;
; ; ; ; ; ; ; ; ; ;
; ; ; ; ;;;;;;;; ; ; ; ;
; ; ; ; ; ; ; ; ;;
; ; ; ; ; ;;;;; ; ;
;Main Program
(defun C:Batch (/ script Alldata path dwglst dwgs)
(setq script "c:/newdwgs.scr")
(alert "Close Excel documents before proceeding.")
(setq Alldata (GetExcel "G:\\Automation\\Drawing Patterns\\AutoCAD STD\\AutoLisp Files\\Excel to IO\\GenerateIO.xlsx" nil nil))
(setq Alldata (cdr Alldata) ;stores the data separate from the column names
path (strcat (BrowseFolder) "\\"))
(foreach data Alldata ;cycles through all lines of data to retrieve dwg name
(setq dwglst (cons (nth 0 data) dwglst))
) ;foreach
(foreach dwg dwglst
(if (null (member dwg dwgs)) ;remove duplicates
(setq dwgs (cons dwg dwgs))
) ;if
) ;foreach
;;; (setq dwgs (apply 'path (dwgs)))
(CreateScript script path dwgs)
(command "_.SCRIPT" script)
(vl-file-delete script)
(princ)
)
;-------------------------------------------------------------------------------------------------------------------------
;This function creates the script file
(defun CreateScript (script path dwgs / f io lsp)
(setq f (open script "w"))
(setq io "G:/Automation/Drawing Patterns/AutoCAD STD/AutoLisp Files/Excel to IO/Insert IO.lsp") ;2nd routine
(setq lsp "G:/Automation/Drawing Patterns/AutoCAD STD/AutoLisp Files/Excel to IO/StartIO.LSP") ;1st routine
(foreach dwg dwgs
(write-line "_.new \"Kice 11X17\"" f)
(write-line (strcat "_.saveas 2007 \"" path dwg ".dwg\"") f)
(write-line (strcat "(load \"" lsp "\")") f)
(write-line "DwgSetup" f)
(write-line (strcat "(load \"" io "\")") f)
(write-line "insertio" f)
(write-line "_.qsave" f)
(write-line "_.close" f)
) ;foreach
(write-line "" f)
(close f)
) ;defun
;-------------------------------------------------------------------------------------------------------------------------
;This function prepares the drawing to add to active project and update titleblock
(defun C:DwgSetup (/ DName Dwg SheetDName bk ss en) ;1st rountine
(setq Dwg "IO"
DName (getvar "DWGNAME"))
(setq SheetDName (substr DName 4 2)) ;retrieving sheet no i.e. AA
(setq ss (ssget "X" '((0 . "INSERT") (2 . "wd_m")))) ;locating block to modify attributes
(setq sslen (sslength ss)) ;# of blocks inserted
(setq bk -1) ;counter
(while (< (setq bk (1+ bk)) sslen)
(setq en (ssname ss bk))
(c:wd_modattrval en "SHEET" SheetDName nil)
(c:wd_modattrval en "SHEETDWGNAME" Dwg nil)
(c:wd_ladr_reref) ;update ladder numbers
(c:ace_add_dwg_to_project nil nil) ;add active drawing to active project
(c:wd_tb_process_one 0 (list (list 0 0 0 0 0 0 1 1 0 0 1 1 1) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)) ;update titleblock
(c:match_proj_properties)
;(c:insertio)
) ;while
) ;defun
;-------------------------------------------------------------------------------------------------------------------------
;This function opens a file dialog box for user to select a folder
(defun BrowseFolder (/ ShlObj Folder FldObj OutVal)
(setq ShlObj (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application")
Folder (vlax-invoke-method ShlObj 'BrowseForFolder 0 "" 0)
) ;setq
(vlax-release-object ShlObj)
(if Folder
(progn
(setq FldObj (vlax-get-property Folder 'Self)
OutVal (vlax-get-property FldObj 'Path)
) ;setq
(vlax-release-object Folder)
(vlax-release-object FldObj)
OutVal
) ;progn
) ;if
) ;defun