Hi,I'm opening the file by function:
Now, I can open file and edit it.I want to delete all sheets with out one called "Detail"
But I got error : Object doesn't support this property or methodwhat is wrong here ?
Code:
Function OpenFile(extFilterName As String, extFilter As String, nameFilter As String) As StringOn Error GoTo ErrHDim fDialog As Office.FileDialogSet fDialog = Application.FileDialog(msoFileDialogOpen)With fDialog .Filters.Clear .Filters.Add extFilterName, extFilter .InitialFileName = nameFilterEnd WithfDialog.ShowOpenFile = fDialog.SelectedItems.Item(1)Exit FunctionErrH: OpenFile = ""End Function
Code:
Dim snapshotDate, FileToOpen, sourceFile, outputFile As StringDim DefaultDate As DateDim TextLine() As IntegerDim i As LongDim k, NumShts As VariantDim sourceWb As WorkbookDim LastRow As DoubleDim dateColumns As VariantFileToOpen = OpenFile("XLS Files", "*.xls", ThisWorkbook.Path & "\Source data\SiteMinder\import\Siteminder Migration Status Report_.xls") If FileToOpen <> "" Then DefaultDate = Now() snapshotDate = InputBox("Input date in format dd/mm/yyyy", , Format(DefaultDate, "dd/mm/yyyy")) Set sourceWb = GetObject(FileToOpen) For Each k In sourceWb If Not k.Name Like "*Detail*" Then k.Delete NumShts = sourceWb.Worksheets.Count ReDim myArray(1 To NumShts) End If Next