LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default Getting file name from the file path error

I created a macro that imports a file into Excel 2007 and with Bob Phillips
help was able to extract the file name from the path. The code works fine on
my computer (I have VB6 installed), but when other users run the macro they
get an object library error (they do not have VB6 installed). Is there a way
to modify the Function GetFileName so that it will work using Excel VBA code?
Below is the code so far. any and all suggestions are greatly welcomed.

Dim myFileName As Variant
Sub ImportRunData()
1 ImportDisplayRDFile
2 If myFileName < False Then GetFileName (myFileName)
End Sub
Sub ImportDisplayRDFile()
'
'ImportRunDataFile Macro
'
'This macro will import and display a DSS Furnace RD file in Excel
'
'THIS SECTION ALLOWS THE USER TO NAVIGATE TO THE FILE LOCATION AND
IMPORT IT CORRECTLY
1 myFileName = Application.GetOpenFilename(FileFilter:="Text Files,
*.csv")
2 If myFileName = False Then
3 Exit Sub 'user hit cancle
4 End If
5 Sheets("Sheet1").Select
6 With ActiveSheet
7 With .QueryTables.Add(Connection:="Text;" & myFileName,
Destination:=.Range("$AG$1"))
8 .Name = "Pick Place for JRB001078B DDU"
9 .FieldNames = True
10 .RowNumbers = False
11 .FillAdjacentFormulas = False
12 .PreserveFormatting = True
13 .RefreshOnFileOpen = False
14 .RefreshStyle = xlInsertDeleteCells
15 .SavePassword = False
16 .SaveData = True
17 .AdjustColumnWidth = True
18 .RefreshPeriod = 0
19 .TextFilePromptOnRefresh = False
20 .TextFilePlatform = 437
21 .TextFileStartRow = 1
22 .TextFileParseType = xlDelimited
23 .TextFileTextQualifier = xlTextQualifierDoubleQuote
24 .TextFileConsecutiveDelimiter = False
25 .TextFileTabDelimiter = True
26 .TextFileSemicolonDelimiter = False
27 .TextFileCommaDelimiter = True
28 .TextFileSpaceDelimiter = False
29 .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 _
, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1)
30 .TextFileTrailingMinusNumbers = True
31 .Refresh BackgroundQuery:=False
32 End With
33 Application.ScreenUpdating = False
34 Sheets("Sheet1").Select
35 Range("P7").Select
36 Selection.NumberFormat = "[h]:mm"
37 Range("G9").Select
38 Selection.NumberFormat = "[h]:mm"
39 Range("L9").Select
40 Selection.NumberFormat = "[h]:mm"
41 Range("Q9").Select
42 Selection.NumberFormat = "[h]:mm"
43 Range("V9").Select
44 Selection.NumberFormat = "[h]:mm"
45 Range("V13").Select
46 Selection.NumberFormat = "[h]:mm"
47 Range("AA9").Select
48 Selection.NumberFormat = "[h]:mm"
49 Range("AG1:DM4200").Select
50 Selection.Copy
51 Sheets("RUN DATA FILE").Select
52 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
53 Application.CutCopyMode = False
54 Range("A1").Select
55 Sheets("Sheet1").Select
56 Range("B1").Select
57 End With
End Sub
Function GetFileName(stFullName As String) As String
GetFileName = Right$(stFullName, Len(stFullName) - InStrRev(stFullName,
Application.PathSeparator))
Range("F5") = GetFileName
End Function
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM
Path/File access error Scott Excel Programming 0 June 8th 06 03:35 PM
Run-time error 75 Path/File access error Casey[_89_] Excel Programming 2 May 9th 06 07:20 PM
Path/File access error (Error 75) using Name Statement blayne Excel Programming 7 November 22nd 05 09:20 PM
Path/File access error (Error 75) after using Name Statement blayne Excel Programming 0 November 10th 05 12:33 AM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"