Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default extract path from FullName

I have this working, but would like to know if there is a way to do this
without using my tempDir variable (just can't wrap my head around this!).

The goal is to strip off the filename and one folder name. Here is what I
am using:
fullPath = ActiveWorkbook.FullName
tempDir = Left(fullPath, InStrRev(fullPath, "\") - 1)
exportDir = Left(fullPath, InStrRev(fullPath, "\") - 1)

Can this be done without tempDir?

Thank you,
Judy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default extract path from FullName

Yes, mainly because your code is not making use of the tempDir variable.

--
Rick (MVP - Excel)


"Judy Ward" wrote in message
...
I have this working, but would like to know if there is a way to do this
without using my tempDir variable (just can't wrap my head around this!).

The goal is to strip off the filename and one folder name. Here is what I
am using:
fullPath = ActiveWorkbook.FullName
tempDir = Left(fullPath, InStrRev(fullPath, "\") - 1)
exportDir = Left(fullPath, InStrRev(fullPath, "\") - 1)

Can this be done without tempDir?

Thank you,
Judy


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default extract path from FullName

I'm sorry. Please pardon the typo, was trying to include only the applicable
lines and not all of my code.

The code below should have been:
fullPath = ActiveWorkbook.FullName
tempDir = Left(fullPath, InStrRev(fullPath, "\") - 1)
exportDir = Left(tempDir, InStrRev(tempDir, "\"))

If I say I'm sorry can I still get some help with this?

Thank you,
Judy

"Rick Rothstein" wrote:

Yes, mainly because your code is not making use of the tempDir variable.

--
Rick (MVP - Excel)


"Judy Ward" wrote in message
...
I have this working, but would like to know if there is a way to do this
without using my tempDir variable (just can't wrap my head around this!).

The goal is to strip off the filename and one folder name. Here is what I
am using:
fullPath = ActiveWorkbook.FullName
tempDir = Left(fullPath, InStrRev(fullPath, "\") - 1)
exportDir = Left(fullPath, InStrRev(fullPath, "\") - 1)

Can this be done without tempDir?

Thank you,
Judy



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default extract path from FullName

You could use activeworkbook.path and just do it once.

Judy Ward wrote:

I have this working, but would like to know if there is a way to do this
without using my tempDir variable (just can't wrap my head around this!).

The goal is to strip off the filename and one folder name. Here is what I
am using:
fullPath = ActiveWorkbook.FullName
tempDir = Left(fullPath, InStrRev(fullPath, "\") - 1)
exportDir = Left(fullPath, InStrRev(fullPath, "\") - 1)

Can this be done without tempDir?

Thank you,
Judy


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default extract path from FullName

To answer your question, you can eliminate the tempDir variable; but, to do
so, you would have to substitute what it is equal to twice in your last line
(once for each appearance). The code is probably clearer if you leave it as
it. With that said, the point Dave raised is what you should follow.
Application.Path gives you want you want directly...

exportDir = Application.Path

--
Rick (MVP - Excel)


"Judy Ward" wrote in message
...
I'm sorry. Please pardon the typo, was trying to include only the
applicable
lines and not all of my code.

The code below should have been:
fullPath = ActiveWorkbook.FullName
tempDir = Left(fullPath, InStrRev(fullPath, "\") - 1)
exportDir = Left(tempDir, InStrRev(tempDir, "\"))

If I say I'm sorry can I still get some help with this?

Thank you,
Judy

"Rick Rothstein" wrote:

Yes, mainly because your code is not making use of the tempDir variable.

--
Rick (MVP - Excel)


"Judy Ward" wrote in message
...
I have this working, but would like to know if there is a way to do this
without using my tempDir variable (just can't wrap my head around
this!).

The goal is to strip off the filename and one folder name. Here is
what I
am using:
fullPath = ActiveWorkbook.FullName
tempDir = Left(fullPath, InStrRev(fullPath, "\") - 1)
exportDir = Left(fullPath, InStrRev(fullPath, "\") - 1)

Can this be done without tempDir?

Thank you,
Judy




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
How to extract data from File Path DK Excel Programming 16 June 14th 07 01:03 AM
Extract Target path from a shortcut WhytheQ Excel Programming 2 January 12th 06 12:39 PM
extract filename from full path Leung Excel Programming 7 August 3rd 05 10:08 PM
Extract Path From String Andibevan[_2_] Excel Programming 2 June 15th 05 07:04 PM
Split fullname into Drive, Path and Filename Michael Göhring Excel Programming 2 December 12th 03 12:56 PM


All times are GMT +1. The time now is 10:41 AM.

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"