Hjælp til at gennemskue kode........
Hej derJeg håber der er en der har lidt tid til overs til lige at hjælpe mig med at gennemskue noget kode som jeg skal have til at funke uden den spørger hvad fil den skal åbne......
Jeg har en rutine der absolut ber om jeg kører den rutine som jeg skal have hjælp til.....
Det jeg ikke kan finde frem til er hvor jeg skal sætte filnavnet ind i min kode for at den bare åbner den fil jeg vil ha.....
'**************************************************************************
' Purpose: To display a FileOpen dialog box and to intialize clsFile.
' Inputs: Optional arguments allow the caller to change the visual
' appearance of the FileOpen dialog.
' Outputs: Whether or not the file was sucessfully opened.
'**************************************************************************
Public Function OpenFile(Optional vntDefaultExt, Optional vntFlags, _
Optional vntFilter, Optional vntFilterIndex)
Dim intScreenPointer As Integer
On Error Resume Next
intScreenPointer = Screen.MousePointer
With dlg
.CancelError = True
.DefaultExt = IIf(IsMissing(vntDefaultExt), DEFAULT_EXT, vntDefaultExt)
.Flags = IIf(IsMissing(vntFlags), DEFAULT_FLAGS_OPEN, vntFlags)
.Filter = IIf(IsMissing(vntFilter), DEFAULT_FILTER, vntFilter)
.FilterIndex = IIf(IsMissing(vntFilterIndex), 1, vntFilterIndex)
.ShowOpen
Screen.MousePointer = vbHourglass
If Not Err Then
OpenFile = clsFile.OpenFile(.FileName, False)
Else
OpenFile = False
End If
Screen.MousePointer = intScreenPointer
End With
End Function
'**************************************************************************
' Purpose: Opens a binary file for use with the other methods and
' properties in this class.
' Inputs: A filename, and an option to open the file as read-only.
' Outputs: Success or failure of this method.
' Effects: Opens a disk file.
' Assumes: A fully qualified filename (WITH PATH) is provided to
' strFileName.
'**************************************************************************
Public Function OpenFile(strFileName As String, _
blnReadOnly As Boolean) As Boolean
'---------------------------------------------------------------------
' If the file doesn't exist, then stop immediately.
'---------------------------------------------------------------------
If FileExists(strFileName) = False Then Exit Function
'---------------------------------------------------------------------
' Set up an error handler that will exit the function immediately on
' any error.
'---------------------------------------------------------------------
On Error GoTo OpenFile_Err
'---------------------------------------------------------------------
' Open the file the way the user requested.
'
' NOTE
' Read-Only files will be shared, but Read/Write files will be
' Writelocked to prevent other users from opening the file and
' making changes which will be lost when this file is closed.
'---------------------------------------------------------------------
If blnReadOnly Then
Open strFileName For Binary Access Read Shared As mintFileHandle
Else
Open strFileName For Binary Access Read Write Lock Write As mintFileHandle
End If
'---------------------------------------------------------------------
' Since the file was sucessfully opened, then update the class-level
' variables. Also notify the caller that OpenFile succeded.
'---------------------------------------------------------------------
mstrFileName = strFileName
mblnReadOnly = blnReadOnly
mblnFileOpen = True
OpenFile = True
Exit Function
'-------------------------------------------------------------------------
' If an error occurs, then notify the user of the error number and message
' and exit the function.
'-------------------------------------------------------------------------
OpenFile_Err:
MsgBox "Error " & Err.Number & " - " & Err.Description, vbCritical
Exit Function
End Function
Håber der er nogen der kan hjælpe.......
