Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Split fullname into First Middle and Last | Excel Programming | |||
Citrix and FullName | Excel Programming | |||
FullName vs FullNameURLEncoded | Excel Programming | |||
ThisWorkbook.FullName - A different approach | Excel Programming | |||
ThisWorkbook.FullName | Excel Programming |