dwagner3210
New Member
- Joined
- May 20, 2013
- Messages
- 9
I am pretty much a newb re macros. I have a client who has asked me to troubleshoot a macro that was working for a long time. the PC crashed and now the macro does not. I helped them resolve some reference issues when they reloaded the OS. However, they now have a runtime error 424 object required that keeps coming up. It highlights the subroutine bolded at end of this code. I have tried renaming the userform but to no avail. It is running on winxp sp3. Here is code from the module. not even sure if that is what someone needs to troubleshoot. Any suggestions?
Rich (BB code):
Private Sub DoEvent()
UserForm1.DoEvent ' This is called when timer event fires
End Sub
Sub LoadData()
'
' ups Macro
' Macro recorded 11/4/2003 by L Flowers
' Keyboard Shortcut: Ctrl+r
'
' Modified by JLW: Added the following functionality:
' Barcode and Scale Reading capability, and modularized it for more than one PC.
Dim CSVFile As String
Columns("A:A").EntireColumn.AutoFit
Range("A250").Select
ActiveWindow.ScrollRow = 1
'Prior to loading data, sort the scanned information
Columns("A:G").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
' Now looks for txt.csv in the same folder as the spreadsheet
CSVFile = VBAProject.ThisWorkbook.Path & "\txt.csv"
On Error GoTo NoCSVFile 'If we can't load the UPS csv data file, let user know why!
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & CSVFile, Destination _
:=Range("E1"))
.Name = "txt"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 9, 9, 9, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, _
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9)
.Refresh BackgroundQuery:=False
End With
Range("E1").Select
Selection.ClearContents
CurrentRow = 1
Columns("E:E").Select
Selection.Sort Key1:=Range("E1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Columns("F:F").Select
Selection.NumberFormat = "General"
Range("F1").Select
ActiveCell.FormulaR1C1 = "=RC[-5]=RC[-1]"
Range("F1").Select
Selection.Copy
Range("F2:F1000").Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Put focus back on originating cell
Range("A1").Select
Exit Sub
NoCSVFile:
MsgBox "The UPS Data file was not found in the same folder as this spreadsheet. Please ensure that it does.", , "UPS CSV Data File Missing"
Exit Sub
End Sub
Sub ScaleReader()
UserForm1.Show
End Sub
Last edited by a moderator: