Description: Rename a worksheet.
Parameters:
RenameSheet(sPathOriginal As String, sPathTarget As String, sSheetToRename As String, sNewSheetName As String) As Long
|
Parameter |
Meaning |
|
sPathOriginal |
Excel file containing the sheet to be renamed. |
|
sPathTarget |
Can be same as sPathOriginal, otherwise a new workbook is created with the original and newly renamed sheets. |
|
sSheetToRename |
Name of the sheet to rename. |
|
sNewSheetName |
sSheetToRename will be renamed to this value. |
Return Values:
0: Success
-3: Unable to create Excel Application. Is it installed?
-4: Unable to destroy Excel Application.
-200: Excel reported an error
-201: Shareware Expired
-208: Target Path folder does not exist, even after attempting to create it.
-216: Sheet to rename does not exist
Example Code:
Taken from the sample VB program provided, this code demonstrates how a secondary form is displayed for data collection. The information is transferred to variables then passed to the RenameSheet function of the component.
Case SP_XLS_RENAME_SHEET
frmXLSRenameSheet.Show vbModal 'form to collect data
If (frmXLSRenameSheet.bErrorOccurred = True) Then
Exit Sub
Else 'collect the necessary data
strSheetToRename = frmXLSRenameSheet.sSheetToRename
strNewSheetName = frmXLSRenameSheet.sNewSheetName
End If
'call the component with necessary arguments
lngResult = XLSConv1.RenameSheet(strSourceFile, strTargetFile,
strSheetToRename, strNewSheetName)