Get the save name from workbook’s Title property:Set prps = _
appExcel.ActiveWorkbook.BuiltinDocumentPropertiesstrSaveName = strWorksheetPath & prps(“Title”) _
& “ - “ & Format(Date, “d-mmm-yyyy”)
Debug.Print “Worksheet save name: “ & strSaveNameOn Error Resume NextIf there already is a saved worksheet with this name, delete it:Kill strSaveNameOn Error GoTo ErrorHandlerstrPrompt = “Enter file name and path for saving worksheet”
strTitle = “File name”
strDefault = strSaveName
strSaveName = InputBox(prompt:=strPrompt, _
Title:=strTitle, Default:=strDefault)wkb.SaveAs FileName:=strSaveName, _
FileFormat:=xlWorkbookDefault
appExcel.Visible = TrueErrorHandlerExit:
Exit SubErrorHandler:
If Err = 429 ThenExcel is not running; open Excel with CreateObject:Set appExcel = CreateObject(“Excel.Application”)
Resume Next
Else
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit
End IfEnd SubThe procedure first picks up the worksheet template path from the main menu, checks that the
template is to be found in that location, and then creates a new workbook from the template. It
then sets up a recordset based on an Access query, goes to the first data cell in the worksheet, and
starts iterating through the records in the recordset, using the Offsetmethod of the active cell to
place data from each field in the correct column.Part II Writing VBA Code to Exchange Data between Office Components