ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help with: runtime error '13' (https://www.excelbanter.com/excel-programming/378848-need-help-runtime-error-13-a.html)

pape93gyal

Need help with: runtime error '13'
 
i get a runtime error '13' type mismatch when i run my code. can someone help
me with this code. the code basically opens a file, take info from the file
then close the file. when i click debug part of my code highlighted
"if FName < False Then"

Sub OpenFile()
Declaration.ExitForm
FName = Application.GetOpenFilename(filefilter:="DecProFil e(*.XLS), *.XLS",
Title:="Open Declaration Pro File", MultiSelect:=True)
If FName < False Then

Workbooks.Open (FName.Path & "\" & FName)
If ActiveWorkbook.Worksheets("sheet1").Range("A1").Va lue = "DecProFile" Then
'take info from file
Workbooks("Declaration
Pro.xls").Worksheets("Classification").Range("B5:B 103").Value =
ActiveWorkbook.Worksheets("sheet1").Range("B5:B103 ").Value

ActiveWorkbook.Close
Calculate
Else
MsgBox prompt:="Invalid file", Title:="Invalid"
ActiveWorkbook.Close
End If
End If
End Sub

I appreciate your help
Thank you


pape93gyal

Need help with: runtime error '13'
 
ok... i tried this and it works with no problem

Sub OpenFile()
Declaration.ExitForm
Dim fname As String, bk As Workbook
fname = Application.GetOpenFilename()
If fname < "False" Then
Set bk = Workbooks.Open(fname)
If ActiveWorkbook.Worksheets("sheet1").Range("A1").Va lue = "DecProFile" Then
'take info from file
Workbooks("Declaration
Pro.xls").Worksheets("Classification").Range("B5:B 103").Value =
ActiveWorkbook.Worksheets("sheet1").Range("B5:B103 ").Value

ActiveWorkbook.Close
Calculate
Else
MsgBox prompt:="Invalid file", Title:="Invalid"
ActiveWorkbook.Close
Declaration.Show vbModeless
End If
Else
Declaration.Show vbModeless
Exit Sub
End If
End Sub


"pape93gyal" wrote:

i get a runtime error '13' type mismatch when i run my code. can someone help
me with this code. the code basically opens a file, take info from the file
then close the file. when i click debug part of my code highlighted
"if FName < False Then"

Sub OpenFile()
Declaration.ExitForm
FName = Application.GetOpenFilename(filefilter:="DecProFil e(*.XLS), *.XLS",
Title:="Open Declaration Pro File", MultiSelect:=True)
If FName < False Then

Workbooks.Open (FName.Path & "\" & FName)
If ActiveWorkbook.Worksheets("sheet1").Range("A1").Va lue = "DecProFile" Then
'take info from file
Workbooks("Declaration
Pro.xls").Worksheets("Classification").Range("B5:B 103").Value =
ActiveWorkbook.Worksheets("sheet1").Range("B5:B103 ").Value

ActiveWorkbook.Close
Calculate
Else
MsgBox prompt:="Invalid file", Title:="Invalid"
ActiveWorkbook.Close
End If
End If
End Sub

I appreciate your help
Thank you



All times are GMT +1. The time now is 10:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com