Sub Abrir()
CommonDialog1.Filter = "Todos los Archivos (*.*)|*.*|Archivos de texto (*.txt)|*.txt|"
CommonDialog1.FilterIndex = 1
CommonDialog1.ShowOpen
Filename = CommonDialog1.Filename ' designa el nombre del archivo
If Err.Number = 32755 Then Exit Sub 'SI CANCELA
OpenFile (Filename)
End Sub
Sub OpenFile(Filename As String)
Dim F As Integer
Dim file_Texto As String
Dim Arch_Texto As String
If Filename = "" Or Filename = " " Then
MsgBox "Error Archivo no valido", vbInformation, APNotepad
End If
'Exit Sub
If "APNotepad " + Filename = frm_agnotepad.Caption Then
Exit Sub
Else
On Error GoTo etq_Error
F = FreeFile
Open Filename For Input As F
archivo_texto = Input(LOF(F), F)
frm_agnotepad!txt_body.Text = archivo_texto
nombre = Filename
Close F
frm_agnotepad.Caption = "AP Notepad " + Filename
nombre = Filename
End If
dato = Filename
Exit Sub
etq_Error:
MsgBox "Ha ocurrido un error al intentar abrir el archivo.", 48, "APNotepad"
End Sub