View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default ERROR: subscript out of range

'If the workbook is not open
Set wbk = Workbooks.Open("C:\geo13.xls")

'If the workbook is already open (mention only the xls name..If not saved it
would be like book1, book2 etc; withoutt the extension)
Set wbk = Workbooks("geo13.xls")

If this post helps click Yes
---------------
Jacob Skaria


"sam" wrote:

Hi All, I am getting subscript out of range error on this line:

---------------Set wbk = Workbooks("C:\Documents\WorkBook1")

here is my code

Sub Submit_Click()

Dim wbk As Workbook
Dim ws As Worksheet
Dim FName As String

Set wbk = Workbooks("C:\Documents\WorkBook1")

With Worksheets("Sheet1")

Range("A1").Value = Me.Name.Value

End With



FName = "C:\Documents\" _
& "File_of" & "-" & Me.Name.Value & ".xls"

Application.DisplayAlerts = False
With wbk

.SaveAs Filename:=FName

.Close

End With

end sub


Thanks in advance