View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
jimjk jimjk is offline
external usenet poster
 
Posts: 4
Default Macro recently quit working


Thank you for trying again the issue is whyit works with f5 or f8 with
breakpoint but not in auto?



Since this code is what i have been using (excpt for debug portions) it
reacted the same way when I add it to my file. this portion worked but then
failed just like mine did in auto after the 2nd open.

Public HeadLine As String
Public ThisLine As String
Public Checkfilenum
Public TotalRows
Public NDresults

Sub CombineMultFiles()
' CombMultFiles() loads selected text files from disk and calls
' Comb_1 to add the Data (2) worksheet from each file individually
'
'
'
Application.ScreenUpdating = False

'Global initialization
HeadLine = "FirstOne"
Checkfilenum = 0
' Check to see if values were set by add data routine
' and the program called from there

If IsEmpty(TotalRows) Then ' <<<<breakpoint for f5 continue of f8 step
TotalRows = 0
NDresults = 1
End If
' Standard routine for requesting file names
Dim fn As Variant, f As Integer
fn = Application.GetOpenFilename("Text Files (*.txt),*.txt", 1, "Select One
Or More Stat files To Combine/process", , True)
If TypeName(fn) = "Boolean" Then Exit SubIf TypeName(fn) = "Boolean" Then
Exit Sub
End if
'<<<<beep code was tried here
For f = 1 To UBound(fn)

Workbooks.OpenText Filename:=fn(f) _
, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:= _
False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
' ********** file did open ***********

ThisLine = Range("A6").Value ' added breakpoint here but it never got here.
Application.DisplayAlerts = False
Call Comb_1
Next f
Workbooks("dresults.xls").Activate
newfilename = "combinedfiles" + Str(NDresults) + ".xls"
ActiveWorkbook.SaveAs Filename:=newfilename, FileFormat:=xlNormal
Application.ScreenUpdating = True
If Checkfilenum 0 Then
errmes = "There was a total of " + Str(Checkfilenum) + " files that
failed."
MsgBox (errmes)
End If
If NDresults 1 Then
errmes = "There was a total of " + Str(NDresults) + " combinedfiles
created from this data."
MsgBox (errmes)
End If
For I = 1 To 30 ' Loop 3 times.
Beep ' Sound a tone.
Next I

End Sub


"Jacob Skaria" wrote:

Try...........

Dim intTemp As Integer
Dim vartemp As Variant

vartemp = Application.GetOpenFilename(FileFilter:="Text Files
(*.txt),*.txt", _
FilterIndex:=1, Title:="<Your Title", MultiSelect:=True)

If IsArray(vartemp) Then
For intTemp = 1 To UBound(vartemp)
Debug.Print vartemp(intTemp)
Next
End If



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


"jimjk" wrote:

I have a macro which Has been in use for several months. Recently it failed
so I started up the editor and step through the program manually. it worked
like it always did. Tried running in auto the same problem occured. I then
added a breakpoint. It stopped at breakpoint and I hit F5 again it completed
without a hitch. I added some do loops with a Beep and I am hearing the Beeps
before some previous steps are finished. The command before the loop is "fn =
Application.GetOpenFilename("Text Files (*.txt),*.txt", 1, "Select One Or
More Stat files To Combine/process", , True)"