Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Path or Macro Name

Path or Macro Name

Path or Macro Name


i have a macro stored in a particular directory. when i run the macro,
(1) is there a way to return the name of the macro? - or -
(2) is there a way to return the path where the macro is stored?


RE: Path or Macro Name

Assuming you are doing this using VBA from like Excel (yes, assuming...we all know that's bad!)...try utilizing something along the lines of:
Splitting up a filename
The two examples in this section make it easy to extract a path or a filename from a full filespec, such as "c:\files\workbooks\archives\budget98.xls"

Function ExtractFileName(filespec) As String
' Returns a filename from a filespec
Dim x As Variant
x = Split(filespec, Application.PathSeparator)
ExtractFileName = x(UBound(x))
End Function

Function ExtractPathName(filespec) As String
' Returns the path from a filespec
Dim x As Variant
x = Split(filespec, Application.PathSeparator)
ReDim Preserve x(0 To UBound(x) - 1)
ExtractPathName = Join(x, Application.PathSeparator) & _
End FunctionUsing the filespec shown above as the argument, ExtractFileName returns "budget98.xls" and ExtractPathName returns "c:\files\workbooks\archives\"

It appears we aren't allowed to put direct links into post and I don't want to break the rules, but if you Google for "The Spreadhseet Page" and specifically for "The Versatile Split Function" you should be able to find the original resource quoted above.
This is all assuming you are working with an Excel macro that is opening and using an Attachmate session.
If not, just ignore me. spin2

If you bring that sentence in for a fitting, I can have it shortened by Wednesday!

RE: Path or Macro Name

hi DwMcC,

thanks for your thoughts on this. unfortunately, i had to code this in Extra, not VBA. it would have been a breeze with VBA.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close