I am trying to get back a path to a selected file using
the following code, but can only get the filename.

Can anyone help?

Thanks

Sub GetFilePath()
Dim sFilename As String
Dim sFilePath As String
Dim dlgSaveAs As Dialog

Set dlgSaveAs = Dialogs(wdDialogFileOpen)
dlgSaveAs.Display
sFilename = dlgSaveAs.Name
sFilePath = dlgSaveAs.????

MsgBox sFilePath & "\" & sFilename

End Sub

RE: Dialog Boxes Word by anonymous

anonymous
Mon Jan 05 12:56:08 CST 2004

Hi Paula

It looks like you're trying to return the fullname of the file that you've selected. If so, then you can use the following to do that

Sub GetFilePath(
Dim sFullName As Strin
Dim dlgSaveAs As Dialo
Dim f

Set dlgSaveAs = Dialogs(wdDialogFileOpen
With dlgSaveA
.Displa
Set fs = CreateObject("Scripting.FileSystemObject"
sFullName = fs.GetAbsolutePathName(Replace(.Name, Chr(34), "")
End Wit

MsgBox sFullNam
End Su


HTH
Dave

Re: Dialog Boxes Word by Cindy

Cindy
Mon Jan 05 13:47:34 CST 2004

Replied to duplicate question in another group
(docmanagement, maybe?)

Cindy Meister


Re: Dialog Boxes Word by Perry

Perry
Mon Jan 05 14:56:51 CST 2004

You almost had it :-))

Dim sFilename As String
Dim sFilePath As String
Dim dlgSaveAs As Dialog

Set dlgSaveAs = Dialogs(wdDialogFileOpen)
dlgSaveAs.Display
sFilename = dlgSaveAs.Name
sFilePath = CurDir

MsgBox sFilePath & "\" & Replace(sFilename, Chr(34), "")


CurDir returns the current directory/path.
Replace() is used to eliminate the Double quotes in case the filename
as returned from dlgSaveAs.Name, includes a space(s).

Krgrds,
Perry

"Paula" <anonymous@discussions.microsoft.com> wrote in message
news:067601c3d3b4$93f4bdd0$a001280a@phx.gbl...
> I am trying to get back a path to a selected file using
> the following code, but can only get the filename.
>
> Can anyone help?
>
> Thanks
>
> Sub GetFilePath()
> Dim sFilename As String
> Dim sFilePath As String
> Dim dlgSaveAs As Dialog
>
> Set dlgSaveAs = Dialogs(wdDialogFileOpen)
> dlgSaveAs.Display
> sFilename = dlgSaveAs.Name
> sFilePath = dlgSaveAs.????
>
> MsgBox sFilePath & "\" & sFilename
>
> End Sub
>
>



Re: Dialog Boxes Word by beata

beata
Thu Jan 15 03:29:49 CST 2004


Replace doesn't work for Word 97 :( Do you know an similar thing. Rest
of code works fine.

ciao


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


Re: Dialog Boxes Word by Martin

Martin
Fri Jan 16 02:06:10 CST 2004

Hi there

> Replace doesn't work for Word 97 :( Do you know an similar thing. Rest
> of code works fine.

Here's code which simulates the replace functionality:

Function MyReplace(ByVal txt As String, fnd As String, rpl As String) As
String
Dim pos As Integer
' replace first occurence of text fnd until no occurence found
Do
pos = InStr(1, txt, fnd)
If pos = 0 Then Exit Do

txt = Left(txt, pos - 1) + rpl + Mid(txt, pos + Len(fnd))
Loop
MyReplace = txt
End Function

Note, that I used another name to prevent confusion with the built-in
Replace-function of later versions of Office-VBA. The usage, however,
is the same:

... MyReplace( myTextHere, vbCrLf, vbCr) & " "


Cheers,
Martin

"beata" <beata.1041qv@nospam.WordForums.com> schrieb im Newsbeitrag
news:beata.1041qv@nospam.WordForums.com...
>
> Replace doesn't work for Word 97 :( Do you know an similar thing. Rest
> of code works fine.
>
> ciao
>
>
> ------------------------------------------------
> ~~ Message posted from http://www.ExcelTip.com/
> ~~View and post usenet messages directly from http://www.ExcelForum.com/
>