Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with ShowOpen() by CajunCenturion

Status
Not open for further replies.

bpeirson

Structural
Apr 7, 2003
147
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.
 
Replies continue below

Recommended for you

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)
 
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.
 
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.
 
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\[URL unfurl="true"]wwwroot\wpnew\images.dxf"[/URL]
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:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor