Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default File Location code

Hello All,

I'm using the following modified code that was posted
by "Dan E." several weeks ago to write the path of a file
out to a cell. Below is the code:

FileName = Application.GetOpenFilename("Text Files _
(*.txt), *.txt")
CellLocation = Len(FileName) + 1 - InStr(1, StrReverse _
(FileName), "\")
FilePath = Mid(FileName, 1, CellLocation)
Range("G46").Value = FilePath

When I run this code using Excel 97, it gives me the
following error: Sub or Funtion not defined for
"StrReverse". Works fine on Excel 2K, what am I missing?

Thanks in advance,
Rohit
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default File Location code

Hi Rohit

Excel 97 is older than Excel 2000, which is older than Excel XP. Things (here StrReverse)
are invented and added to each new version. Great thing is that nothing is removed. For
cross-version development you /must/ use the oldest version to develop on, or you're
working blindfolded and will be rewarded by error messages like this.

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"Rohit Thomas" wrote in message
...
Hello All,

I'm using the following modified code that was posted
by "Dan E." several weeks ago to write the path of a file
out to a cell. Below is the code:

FileName = Application.GetOpenFilename("Text Files _
(*.txt), *.txt")
CellLocation = Len(FileName) + 1 - InStr(1, StrReverse _
(FileName), "\")
FilePath = Mid(FileName, 1, CellLocation)
Range("G46").Value = FilePath

When I run this code using Excel 97, it gives me the
following error: Sub or Funtion not defined for
"StrReverse". Works fine on Excel 2K, what am I missing?

Thanks in advance,
Rohit



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default File Location code

Hi Rohit,

The reason is the name of the function is InStrRev, not StrRev. Just
change that and the code should be fine.

Let me know if that doesn't work.

Mark

---
Mark Bigelow
mjbigelow at hotmail dot com
http://hm.imperialoiltx.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default File Location code

Herald,

Can I use something in it's place to get the desired
result that I'm looking for? Any suggestions on how I can
use the GetOpenFileName dialog to write the path of a file
to a cell?

Rohit
-----Original Message-----
Hi Rohit

Excel 97 is older than Excel 2000, which is older than

Excel XP. Things (here StrReverse)
are invented and added to each new version. Great thing

is that nothing is removed. For
cross-version development you /must/ use the oldest

version to develop on, or you're
working blindfolded and will be rewarded by error

messages like this.

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"Rohit Thomas" wrote in message
...
Hello All,

I'm using the following modified code that was posted
by "Dan E." several weeks ago to write the path of a

file
out to a cell. Below is the code:

FileName = Application.GetOpenFilename("Text Files _
(*.txt), *.txt")
CellLocation = Len(FileName) + 1 - InStr(1, StrReverse _
(FileName), "\")
FilePath = Mid(FileName, 1, CellLocation)
Range("G46").Value = FilePath

When I run this code using Excel 97, it gives me the
following error: Sub or Funtion not defined for
"StrReverse". Works fine on Excel 2K, what am I missing?

Thanks in advance,
Rohit



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default File Location code

Mark,

It's StrReverse and it reverses a string
ie ABC - CBA

InStrRev is a search tool for searching for one string
within another from the end to the beginning, they are
nothing alike.

Dan E

"Mark Bigelow" wrote in message ...
Hi Rohit,

The reason is the name of the function is InStrRev, not StrRev. Just
change that and the code should be fine.

Let me know if that doesn't work.

Mark

---
Mark Bigelow
mjbigelow at hotmail dot com
http://hm.imperialoiltx.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default File Location code

One way:

Sub test()
Dim filename As String, L As Long
filename = Application.GetOpenFilename("Text Files " & _
"(*.txt), *.txt")
For L = Len(filename) To 1 Step -1
If Mid$(filename, L, 1) = "\" Then Exit For
Next
MsgBox Left$(filename, L - 1)
End Sub

If a folder is all you need selected, then see Jim Rech's "Browse for folder" at
http://www.bmsltd.co.uk/MVP/Default.htm

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"Rohit Thomas" wrote in message
...
Herald,

Can I use something in it's place to get the desired
result that I'm looking for? Any suggestions on how I can
use the GetOpenFileName dialog to write the path of a file
to a cell?

Rohit
-----Original Message-----
Hi Rohit

Excel 97 is older than Excel 2000, which is older than

Excel XP. Things (here StrReverse)
are invented and added to each new version. Great thing

is that nothing is removed. For
cross-version development you /must/ use the oldest

version to develop on, or you're
working blindfolded and will be rewarded by error

messages like this.

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"Rohit Thomas" wrote in message
...
Hello All,

I'm using the following modified code that was posted
by "Dan E." several weeks ago to write the path of a

file
out to a cell. Below is the code:

FileName = Application.GetOpenFilename("Text Files _
(*.txt), *.txt")
CellLocation = Len(FileName) + 1 - InStr(1, StrReverse _
(FileName), "\")
FilePath = Mid(FileName, 1, CellLocation)
Range("G46").Value = FilePath

When I run this code using Excel 97, it gives me the
following error: Sub or Funtion not defined for
"StrReverse". Works fine on Excel 2K, what am I missing?

Thanks in advance,
Rohit



.



Reply
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
Code for a button to change cell location Michael B Excel Discussion (Misc queries) 1 November 30th 07 04:30 PM
file location DaveB Excel Discussion (Misc queries) 4 July 7th 07 10:02 PM
Get File location Jeff Excel Discussion (Misc queries) 2 September 26th 06 08:20 PM
Location of XLB file? Doug Kanter Excel Discussion (Misc queries) 5 February 28th 06 12:40 AM
Specify file location Shunt Excel Programming 0 July 28th 03 04:49 PM


All times are GMT +1. The time now is 11:40 PM.

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

About Us

"It's about Microsoft Excel"