Shariq.khan
New Member
- Joined
- Jun 16, 2011
- Messages
- 5
Hi! I want to Create a Blank Workbook using VB. But I've a problem with following Code:
I'm getting and Error: i.e. Object Required on the Line
With Application.FileSearch.
Plz Help me so that i can complete my work.
My Code is below:
Sub CreateBook()
x = InputBox("Enter WOrkbook Name")
Dim strDir As String
strDir = "E:\Check"
With Application.FileSearch
.LookIn = strDir
.FileName = x & ".xls"
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
Workbooks.Open (strDir & "\" & x & ".xls")
Exit Sub
Else
Workbooks.Add.SaveAs (strDir & "\" & x & ".xls")
ActiveWorkbook.Close
End If
End With
End Sub
I'm getting and Error: i.e. Object Required on the Line
With Application.FileSearch.
Plz Help me so that i can complete my work.
My Code is below:
Sub CreateBook()
x = InputBox("Enter WOrkbook Name")
Dim strDir As String
strDir = "E:\Check"
With Application.FileSearch
.LookIn = strDir
.FileName = x & ".xls"
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
Workbooks.Open (strDir & "\" & x & ".xls")
Exit Sub
Else
Workbooks.Add.SaveAs (strDir & "\" & x & ".xls")
ActiveWorkbook.Close
End If
End With
End Sub