wdDialogFileOpen and .name not working properly

F

FotoArt

hello everyone

I found that the following code(not complete) is not giving the name of the
selected file properly.
Any idea how i can make it work?

With Dialogs(wdDialogFileOpen)
.Display
myPath = CurDir() '& "\" & .Name
myFileName = .Name
End With

any help is appreciated
thanx
ahmed
 
M

macropod

What isn't it dong properly? The following works for me:
Sub Test()
Dim myPath As String
Dim myFileName As String
With Dialogs(wdDialogFileOpen)
.Display
myPath = CurDir()
myFileName = .Name
End With
MsgBox myPath & "\" & myFileName
End Sub
 
F

FotoArt

i thought the .name should give me just the name of the file.
but it is returning the whole file path.

any help is appreciated
thanx
ahmed

macropod said:
What isn't it dong properly? The following works for me:
Sub Test()
Dim myPath As String
Dim myFileName As String
With Dialogs(wdDialogFileOpen)
.Display
myPath = CurDir()
myFileName = .Name
End With
MsgBox myPath & "\" & myFileName
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]


FotoArt said:
hello everyone

I found that the following code(not complete) is not giving the name of the
selected file properly.
Any idea how i can make it work?

With Dialogs(wdDialogFileOpen)
.Display
myPath = CurDir() '& "\" & .Name
myFileName = .Name
End With

any help is appreciated
thanx
ahmed
 
M

macropod

Hi FotoArt,

For me, '.Name' and 'myFileName' both return just the name of the file (ie no path) in both Word 2000 and Word 2007.

--
Cheers
macropod
[MVP - Microsoft Word]


FotoArt said:
i thought the .name should give me just the name of the file.
but it is returning the whole file path.

any help is appreciated
thanx
ahmed

macropod said:
What isn't it dong properly? The following works for me:
Sub Test()
Dim myPath As String
Dim myFileName As String
With Dialogs(wdDialogFileOpen)
.Display
myPath = CurDir()
myFileName = .Name
End With
MsgBox myPath & "\" & myFileName
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]


FotoArt said:
hello everyone

I found that the following code(not complete) is not giving the name of the
selected file properly.
Any idea how i can make it work?

With Dialogs(wdDialogFileOpen)
.Display
myPath = CurDir() '& "\" & .Name
myFileName = .Name
End With

any help is appreciated
thanx
ahmed
 
N

Neil Cumfer

It seems that in Word 2007, the .Name property returns the file name
only if the file is on a local drive, but returns the full path with the
file name
if it is on a network drive

In Word 2007, the Dir() function returns the full path with the file
name
in some cases also.


macropod said:
Hi FotoArt,

For me, '.Name' and 'myFileName' both return just the name of the file
(ie no path) in both Word 2000 and Word 2007.
--
Cheers
macropod
[MVP - Microsoft Word]


i thought the .name should give me just the name of the file.
but it is returning the whole file path.

any help is appreciated
thanx
ahmed

macropod said:
What isn't it dong properly? The following works for me:
Sub Test()
Dim myPath As String
Dim myFileName As String
With Dialogs(wdDialogFileOpen)
.Display
myPath = CurDir()
myFileName = .Name
End With
MsgBox myPath & "\" & myFileName
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]


hello everyone

I found that the following code(not complete) is not giving the name of the
selected file properly.
Any idea how i can make it work?

With Dialogs(wdDialogFileOpen)
.Display
myPath = CurDir() '& "\" & .Name
myFileName = .Name
End With

any help is appreciated
thanx
ahmed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top