Hey guys,
I have the following code which is run by a form. It imports text via connection. However, I notice that every time I run it it creates an Add-in and names it by whatever value cboRptname (a combobox field on the form) has. This creates a real nuisance as every time I open Excel (thereafter) it gives me a message that that add-in is not found:
Is there a way I need to rewrite the above to avoid that? As well, how do I provide to give the user a message if the text file location is not found?
Thanks a ton
Ron
I have the following code which is run by a form. It imports text via connection. However, I notice that every time I run it it creates an Add-in and names it by whatever value cboRptname (a combobox field on the form) has. This creates a real nuisance as every time I open Excel (thereafter) it gives me a message that that add-in is not found:
Code:
Private Sub ImportText()
Set ws1 = Sheets(cboRptname.Value)
ws1.Activate
With ws1
ActiveSheet.AutoFilterMode = False
ActiveWindow.FreezePanes = False
ws1.UsedRange.Clear
End With
With ws1.QueryTables.Add(Connection:= _
"TEXT;\\nbsmain\Archive\sxxirpts\" & cboYear.Value & " " & cboMonth.Value & " Sxxi Reports\Main\" & cboMonth.Value & cboDay.Value & "\F99999\" & cboRptname.Value & ".999", Destination:= _
ws1.Range("$A$1"))
'\\nbsmain\Archive\sxxirpts\2011 03 Sxxi Reports\Main\0331\F99999\PSAV00.999
.Name = "cboRptname.Value"
.FieldNames = True
.PreserveFormatting = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileOtherDelimiter = "|"
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Is there a way I need to rewrite the above to avoid that? As well, how do I provide to give the user a message if the text file location is not found?
Thanks a ton
Ron