View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Darren Hill Darren Hill is offline
external usenet poster
 
Posts: 47
Default On Error GoTo .... error

UYou have an On Error Resume Next at the start of your code. Should that
be there? It tells excel to ignore errors.

wrote:
Well, i've got a workaround done, but if anybody has any clues as to
why the On Error functions aren't working, feel free to chime in here.

Private Sub cmb_OpenProjectFile_Click()
Dim pfilename As Variant

On Error Resume Next
beginning:

original_workbook = ActiveWorkbook.Name
pfilename = Application.GetOpenFilename("Excel File (*.xls),*.xls", ,
"Select the file to merge")

slashloc = InStr(1, pfilename, "\", vbTextCompare)
Do Until slashloc = 0
slash_loc = slashloc
slashloc = InStr(slashloc + 1, pfilename, "\", vbTextCompare)
Loop
Filename = Right(pfilename, Len(pfilename) - slash_loc)

If pfilename < False Then
If Filename < ActiveWorkbook.Name Then
On Error GoTo beginning
Application.Workbooks.Open (pfilename)
If ActiveWorkbook.Name = original_workbook Then _
GoTo beginning
usf_MergeData.cbo_selectProjectFile.Text =
ActiveWorkbook.Name
usf_MergeData.cbo_selectProjectFile.AddItem
ActiveWorkbook.Name

usf_MergeData.cbo_selectProjectFile.BoundColumn = 0
End If
End If

End Sub

Regards,
Thedude