Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default How to Get Files.FullName

I have macro (see below) which put all kind of files names in ListBox1
from specified folder

Private Sub CommandButton1_Click()
Me.ListBox1.Clear
Dim Filename As String
Dim Foldername As String

Foldername = "C:\Documents and Settings\Files\"
Filename = Dir(Foldername)
Do Until Filename = ""
Me.ListBox1.AddItem (Filename)
Filename = Dir
Loop
End Sub

How can I get files full name or path in ListBox1. For example get
name like "C:\Documents and Settings\Files\Flag.pdf" instead of
"Flag.pdf". I know there is some modification needed in macro above
can any friend help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to Get Files.FullName

Replace
Me.ListBox1.AddItem (Filename)

with
Me.ListBox1.AddItem FolderName & FileName

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 07:42:37 -0800 (PST), K
wrote:

I have macro (see below) which put all kind of files names in ListBox1
from specified folder

Private Sub CommandButton1_Click()
Me.ListBox1.Clear
Dim Filename As String
Dim Foldername As String

Foldername = "C:\Documents and Settings\Files\"
Filename = Dir(Foldername)
Do Until Filename = ""
Me.ListBox1.AddItem (Filename)
Filename = Dir
Loop
End Sub

How can I get files full name or path in ListBox1. For example get
name like "C:\Documents and Settings\Files\Flag.pdf" instead of
"Flag.pdf". I know there is some modification needed in macro above
can any friend help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default How to Get Files.FullName

On Feb 18, 3:54*pm, Chip Pearson wrote:
ReplaceMe.ListBox1.AddItem (Filename)

with
Me.ListBox1.AddItem FolderName & FileName

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
* * Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLCwww.cpearson.com
(email on web site)

On Wed, 18 Feb 2009 07:42:37 -0800 (PST), K
wrote:



I have macro (see below) which put all kind of files names in ListBox1
from specified folder


Private Sub CommandButton1_Click()
Me.ListBox1.Clear
Dim Filename As String
Dim Foldername As String


Foldername = "C:\Documents and Settings\Files\"
Filename = Dir(Foldername)
Do Until Filename = ""
Me.ListBox1.AddItem (Filename)
Filename = Dir
Loop
End Sub


How can I get files full name or path in ListBox1. For example get
name like "C:\Documents and Settings\Files\Flag.pdf" instead of
"Flag.pdf". *I know there is some modification needed in macro above
can any friend help.- Hide quoted text -


- Show quoted text -


thanks
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default How to Get Files.FullName

On Feb 18, 3:54*pm, Chip Pearson wrote:
ReplaceMe.ListBox1.AddItem (Filename)

with
Me.ListBox1.AddItem FolderName & FileName

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
* * Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLCwww.cpearson.com
(email on web site)

On Wed, 18 Feb 2009 07:42:37 -0800 (PST), K
wrote:



I have macro (see below) which put all kind of files names in ListBox1
from specified folder


Private Sub CommandButton1_Click()
Me.ListBox1.Clear
Dim Filename As String
Dim Foldername As String


Foldername = "C:\Documents and Settings\Files\"
Filename = Dir(Foldername)
Do Until Filename = ""
Me.ListBox1.AddItem (Filename)
Filename = Dir
Loop
End Sub


How can I get files full name or path in ListBox1. For example get
name like "C:\Documents and Settings\Files\Flag.pdf" instead of
"Flag.pdf". *I know there is some modification needed in macro above
can any friend help.- Hide quoted text -


- Show quoted text -


Hi Chip I changed my macro little bit (see bleow) but I am getting
problem which that when I select on C: drive from Browse Folder then I
get result like C:\\jack.pdf but if select Folder in C: drive then it
work ok like then it comes C:\My Document\jack.pdf. Can you please
help that how can i make C:\\ to C:\ if i select on C: drive

Sub GetFiles()
Sheets(1).ListBox1.Clear
Dim Filename As String
Dim Foldername As String
Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "CHOSE FOLDER:", 0, 17)

If (Not objFolder Is Nothing) Then
Foldername = objFolder.self.Path & "\"
Filename = Dir(Foldername)
Do Until Filename = ""
Sheets(1).ListBox1.AddItem (Foldername & Filename)
Filename = Dir
Loop
Sheets(1).ListBox1.AddItem ""
End If
End Sub
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to Get Files.FullName


Change

Foldername = objFolder.self.Path & "\"

to

Foldername = objFolder.self.Path
If StrComp(Right(Foldername, 1), "\", vbBinaryCompare) < 0 Then
Foldername = Foldername & "\"
End If



Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)'


On Wed, 18 Feb 2009 08:55:34 -0800 (PST), K
wrote:

On Feb 18, 3:54*pm, Chip Pearson wrote:
ReplaceMe.ListBox1.AddItem (Filename)

with
Me.ListBox1.AddItem FolderName & FileName

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
* * Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLCwww.cpearson.com
(email on web site)

On Wed, 18 Feb 2009 07:42:37 -0800 (PST), K
wrote:



I have macro (see below) which put all kind of files names in ListBox1
from specified folder


Private Sub CommandButton1_Click()
Me.ListBox1.Clear
Dim Filename As String
Dim Foldername As String


Foldername = "C:\Documents and Settings\Files\"
Filename = Dir(Foldername)
Do Until Filename = ""
Me.ListBox1.AddItem (Filename)
Filename = Dir
Loop
End Sub


How can I get files full name or path in ListBox1. For example get
name like "C:\Documents and Settings\Files\Flag.pdf" instead of
"Flag.pdf". *I know there is some modification needed in macro above
can any friend help.- Hide quoted text -


- Show quoted text -


Hi Chip I changed my macro little bit (see bleow) but I am getting
problem which that when I select on C: drive from Browse Folder then I
get result like C:\\jack.pdf but if select Folder in C: drive then it
work ok like then it comes C:\My Document\jack.pdf. Can you please
help that how can i make C:\\ to C:\ if i select on C: drive

Sub GetFiles()
Sheets(1).ListBox1.Clear
Dim Filename As String
Dim Foldername As String
Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "CHOSE FOLDER:", 0, 17)

If (Not objFolder Is Nothing) Then
Foldername = objFolder.self.Path & "\"
Filename = Dir(Foldername)
Do Until Filename = ""
Sheets(1).ListBox1.AddItem (Foldername & Filename)
Filename = Dir
Loop
Sheets(1).ListBox1.AddItem ""
End If
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default How to Get Files.FullName

On 18 Feb, 21:36, Chip Pearson wrote:
Change

* * * * Foldername = objFolder.self.Path & "\"

to

Foldername = objFolder.self.Path
If StrComp(Right(Foldername, 1), "\", vbBinaryCompare) < 0 Then
* * * * Foldername = Foldername & "\"
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
* * Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLCwww.cpearson.com
(email on web site)'

On Wed, 18 Feb 2009 08:55:34 -0800 (PST), K
wrote:



On Feb 18, 3:54*pm, Chip Pearson wrote:
ReplaceMe.ListBox1.AddItem (Filename)


with
Me.ListBox1.AddItem FolderName & FileName


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
* * Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLCwww.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 07:42:37 -0800 (PST), K
wrote:


I have macro (see below) which put all kind of files names in ListBox1
from specified folder


Private Sub CommandButton1_Click()
Me.ListBox1.Clear
Dim Filename As String
Dim Foldername As String


Foldername = "C:\Documents and Settings\Files\"
Filename = Dir(Foldername)
Do Until Filename = ""
Me.ListBox1.AddItem (Filename)
Filename = Dir
Loop
End Sub


How can I get files full name or path in ListBox1. For example get
name like "C:\Documents and Settings\Files\Flag.pdf" instead of
"Flag.pdf". *I know there is some modification needed in macro above
can any friend help.- Hide quoted text -


- Show quoted text -


Hi Chip I changed my macro little bit (see bleow) but I am getting
problem which that when I select on C: drive from Browse Folder then I
get result like C:\\jack.pdf but if select Folder in C: drive then it
work ok like then it comes C:\My Document\jack.pdf. *Can you please
help that how can i make C:\\ to C:\ if i select on C: drive


Sub GetFiles()
Sheets(1).ListBox1.Clear
Dim Filename As String
Dim Foldername As String
Dim objShell
Dim objFolder


Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "CHOSE FOLDER:", 0, 17)


If (Not objFolder Is Nothing) Then
Foldername = objFolder.self.Path & "\"
Filename = Dir(Foldername)
Do Until Filename = ""
Sheets(1).ListBox1.AddItem (Foldername & Filename)
Filename = Dir
Loop
Sheets(1).ListBox1.AddItem ""
End If
End Sub- Hide quoted text -


- Show quoted text -


Thanks Chip for your help
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
Split fullname into First Middle and Last Trish Smith Excel Programming 18 August 11th 08 09:55 PM
Citrix and FullName Jonathan West Excel Programming 0 August 6th 08 03:25 PM
FullName vs FullNameURLEncoded Posse John Excel Programming 1 August 20th 06 02:41 PM
ThisWorkbook.FullName - A different approach Steph[_3_] Excel Programming 2 November 23rd 04 09:14 PM
ThisWorkbook.FullName Steph[_3_] Excel Programming 3 November 23rd 04 08:41 PM


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"