×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-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!
  • Students Click Here

*Eng-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

Jobs

Help with ShowOpen() by CajunCenturion

Help with ShowOpen() by CajunCenturion

Help with ShowOpen() by CajunCenturion

(OP)
I searched the archives and found function ShowOpen() and function ShowSave() by CajunCenturion in thread766-100581 (Aug 2004). Both work great with a slight modification;

CODE

      .tLng_hWndOwner = Me.hWnd
      .tLng_hInstance = App.hInstance
must read

CODE

      .tLng_hWndOwner = Application.hWnd
      .tLng_hInstance = Application.hInstance
on my system.

How do I extract the filename from ShowOpen() without the entire path included in the string? I will post the code if required.

RE: Help with ShowOpen() by CajunCenturion

if PN contains the full path name use the following function to reverse the character order in PN

Function ReverseString(inString As String) As String
  Dim lngLen As Long
  lngLen = Len(inString)
  If lngLen <= 1 Then
    ReverseString = inString
  Else
    ReverseString = Right(inString, 1) _
                  & ReverseString(Left(inString, lngLen - 1))
  End If
End Function

ie. rPN =ReverseString(PN)
now search for the first instance of "\" character using the built in function InStr, ie

iPos= InStr(1,rPN,"\")

Finally return the filename using Right function

FN=Right(PN,iPos-1)

RE: Help with ShowOpen() by CajunCenturion

(OP)
Thanks, I was having problems resolving variable numbers of "\" in various filenames. I had resorted to pasting the full path into a worksheet and using excel functions because I am more familiar with excel than VBA. It occurred to me that someone must know a simpler way.

RE: Help with ShowOpen() by CajunCenturion

(OP)
cummings54, thanks, it works well.

johnwm, less code but it doesn't work as well. The filename returned always included the folder "Foldername\filename.dxf". I tried to change the compare options of the function but no luck.

The next phase is to predetermine the path and filename which is used to save the file with the showsave() function.
I will need to change the extension of the filename as well.

Any help is appreciated.

RE: Help with ShowOpen() by CajunCenturion

InstrRev has always worked for me

CODE

Public Function myFilename(ByVal fn As String) As String
myFilename = Mid$(fn, InStrRev(fn, "\") + 1)
End Function

Use as

CODE

f = "F:\My Documents\Inetpub\wwwroot\wpnew\images.dxf"
Debug.Print myFilename(f)
It produces images.dxf for me.

To change the file name use the MID$ command

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

Steam Engine enthusiasts: www.essexsteam.co.uk

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 Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

Click Here to join Eng-Tips and talk with other members!


Resources