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?
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) & _
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.
If you bring that sentence in for a fitting, I can have it shortened by Wednesday!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.