Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import File with browse and select (even from Pocket PC?)

Hi -
I need to create a user form that imports a .CSV file, then allows the
user to scroll through the imported records and display the selected
record(s) individually on a report (with chart) on a second user form.
I have the import of a constant file name partially working, but I want
to offer the user the standard Windows feature "enter the file name or
click the Browse button to select a file". I believe I need to use a
standard Windows component in VBA to do this, but can't find the right
component (nor the time to figure this all out by my deadline). The
files are coming from a Pocket PC, so ideally the Browse capability
would drill through the ActiveSync connection and allow access to the
files which are stored in a folder within the Program Files directory
(a system folder). Without the browse capability to the Pocket PC, I
plan to have the users drag the .CSV file from the Pocket PC to a place
on their hard drive (or go to the Pocket PC backup file), where the
selection method above would pull them in.

Any help would be very much appreciated. I'll submit another post for
the functionality for multi-select and scroll through the selected
records.
Thanks in advance,
Brett Strouss
bstrouss at sensoryarts.com
http://www.pockethearo.com



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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Import File with browse and select (even from Pocket PC?)

Brett,

Here is some code to browse folderrs in a Windows style. I have no
experience of PocketPC, but I would assume that when conected it would look
like a pseudo-drive that can be browsed as normal.

This is a demo of how to use it

MsgBox GetFolder

Use the returned value to set the directory before saving.e.g
myDir = GetFolder
ChDrive myDir
CurDir myDir


At the end I add a previous response from Dave Peterson on a new dialog
added in XL2002 that also does it. Take your pick.



'==============================
'Code starts here

Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As String) As Long

Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

'-------------------------------------------------------------
Function GetFolder(Optional ByVal Name As String = "Select a folder.")
As String
'-------------------------------------------------------------
Dim bInfo As BROWSEINFO
Dim path As String
Dim oDialog As Long

bInfo.pidlRoot = 0& 'Root folder = Desktop

bInfo.lpszTitle = Name

bInfo.ulFlags = &H1 'Type of directory to
return
oDialog = SHBrowseForFolder(bInfo) 'display the dialog

'Parse the result
path = Space$(512)

GetFolder = ""
If SHGetPathFromIDList(ByVal oDialog, ByVal path) Then
GetFolder = Left(path, InStr(path, Chr$(0)) - 1)
End If

End Function



XL2002 solution

Sub GetFolderName()
Dim i As Integer
With Application.FileDialog(msoFileDialogFolderPicker)
..Show
If .SelectedItems.Count = 0 Then Exit Sub
i = .SelectedItems.Count
MsgBox .SelectedItems(i)
End With
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Brett9" wrote in message
...
Hi -
I need to create a user form that imports a .CSV file, then allows the
user to scroll through the imported records and display the selected
record(s) individually on a report (with chart) on a second user form.
I have the import of a constant file name partially working, but I want
to offer the user the standard Windows feature "enter the file name or
click the Browse button to select a file". I believe I need to use a
standard Windows component in VBA to do this, but can't find the right
component (nor the time to figure this all out by my deadline). The
files are coming from a Pocket PC, so ideally the Browse capability
would drill through the ActiveSync connection and allow access to the
files which are stored in a folder within the Program Files directory
(a system folder). Without the browse capability to the Pocket PC, I
plan to have the users drag the .CSV file from the Pocket PC to a place
on their hard drive (or go to the Pocket PC backup file), where the
selection method above would pull them in.

Any help would be very much appreciated. I'll submit another post for
the functionality for multi-select and scroll through the selected
records.
Thanks in advance,
Brett Strouss
bstrouss at sensoryarts.com
http://www.pockethearo.com



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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Import File with browse and select (even from Pocket PC?)

Brett,
Try the function
Application.GetOpenFilename()
It operates exactly like the usual File Open requester but
will return the file name without opening the file. I
assume the PocketPC will appear as a extra drive in the
usual directory structure

Kevin Beckham

-----Original Message-----
Brett,

Here is some code to browse folderrs in a Windows style.

I have no
experience of PocketPC, but I would assume that when

conected it would look
like a pseudo-drive that can be browsed as normal.

This is a demo of how to use it

MsgBox GetFolder

Use the returned value to set the directory before

saving.e.g
myDir = GetFolder
ChDrive myDir
CurDir myDir


At the end I add a previous response from Dave Peterson

on a new dialog
added in XL2002 that also does it. Take your pick.



'==============================
'Code starts here

Private Declare Function SHGetPathFromIDList

Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As String) As Long

Private Declare Function SHBrowseForFolder

Lib "shell32.dll" _
Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

'-----------------------------------------------------

--------
Function GetFolder(Optional ByVal Name As String

= "Select a folder.")
As String
'-----------------------------------------------------

--------
Dim bInfo As BROWSEINFO
Dim path As String
Dim oDialog As Long

bInfo.pidlRoot = 0& 'Root

folder = Desktop

bInfo.lpszTitle = Name

bInfo.ulFlags = &H1 'Type

of directory to
return
oDialog = SHBrowseForFolder

(bInfo) 'display the dialog

'Parse the result
path = Space$(512)

GetFolder = ""
If SHGetPathFromIDList(ByVal oDialog, ByVal path)

Then
GetFolder = Left(path, InStr(path, Chr$(0)) -

1)
End If

End Function



XL2002 solution

Sub GetFolderName()
Dim i As Integer
With Application.FileDialog(msoFileDialogFolderPicker)
..Show
If .SelectedItems.Count = 0 Then Exit Sub
i = .SelectedItems.Count
MsgBox .SelectedItems(i)
End With
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Brett9" wrote in

message
...
Hi -
I need to create a user form that imports a .CSV file,

then allows the
user to scroll through the imported records and display

the selected
record(s) individually on a report (with chart) on a

second user form.
I have the import of a constant file name partially

working, but I want
to offer the user the standard Windows feature "enter

the file name or
click the Browse button to select a file". I believe I

need to use a
standard Windows component in VBA to do this, but can't

find the right
component (nor the time to figure this all out by my

deadline). The
files are coming from a Pocket PC, so ideally the

Browse capability
would drill through the ActiveSync connection and allow

access to the
files which are stored in a folder within the Program

Files directory
(a system folder). Without the browse capability to

the Pocket PC, I
plan to have the users drag the .CSV file from the

Pocket PC to a place
on their hard drive (or go to the Pocket PC backup

file), where the
selection method above would pull them in.

Any help would be very much appreciated. I'll submit

another post for
the functionality for multi-select and scroll through

the selected
records.
Thanks in advance,
Brett Strouss
bstrouss at sensoryarts.com
http://www.pockethearo.com



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

http://www.ExcelForum.com/



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import File with browse and select (even from Pocket PC?)


Thanks to both Bob and Kevin for quick and thorough responses. Kevin's
approach was simple, straight forward, and got me the entire file name,
so I used it. Just a few lines of code and a couple of controls.
Fantastic!

By the way - I found some excellent material on Chip Pearson's site
that will / has saved me a load of time. I recommend it highly!
http://www.cpearson.com

Best regards,
Brett Strouss
bstrouss at sensoryarts.com
http://www.pockethearo.com


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

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
why can't i browse to a location to save a flat file willa212 Excel Discussion (Misc queries) 0 April 2nd 10 12:16 AM
Browse For a File or Path and enter in a cell D. Jones Excel Discussion (Misc queries) 5 November 9th 07 04:07 PM
Browse File for Mac John Vickers Excel Discussion (Misc queries) 1 February 17th 06 06:23 PM
can't browse file k_anucha Excel Discussion (Misc queries) 1 September 29th 05 01:51 AM
Need to browse 100's of file TITLES in Excel 2000 jeffbro27707 Excel Discussion (Misc queries) 3 May 2nd 05 08:46 PM


All times are GMT +1. The time now is 10:09 AM.

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

About Us

"It's about Microsoft Excel"