PC Review


Reply
Thread Tools Rate Thread

Can VBA take user input (form?), search and locate file, retreive data and output?

 
 
Guest
Posts: n/a
 
      27th Jun 2006
Hi everyone. I am a VBAby that needs to learn fast, so any help is truly
appreciated. My first problem is to write a program that accepts user input,
say a file name from a form or even a cell in Excel, locates the file (even
if it's in another directory), extracts data from the file based on a given
range name (more user input) and prints the data to an output line contained
in the same sheet/form as the input. Can all this be done? Can any of it?
Any help to get me started will be most welcome!


 
Reply With Quote
 
 
 
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      27th Jun 2006
The first thing to do would be to ask in a newsgroup about Excel like
microsoft.public.excel.

The second thing would be to split your problem in its basic parts and if
necessary, ask each part (or question) into its appropriate newsgroup. For
exemple, locating a file by making a full search of all disk drives and
repertories has more to do with files and scripting technologies (search
Google for Scripting.FileSystemObject) than with Excel or Access.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


<(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi everyone. I am a VBAby that needs to learn fast, so any help is truly
> appreciated. My first problem is to write a program that accepts user
> input, say a file name from a form or even a cell in Excel, locates the
> file (even if it's in another directory), extracts data from the file
> based on a given range name (more user input) and prints the data to an
> output line contained in the same sheet/form as the input. Can all this be
> done? Can any of it? Any help to get me started will be most welcome!
>



 
Reply With Quote
 
Nikos Yannacopoulos
Guest
Posts: n/a
 
      27th Jun 2006
Dr Jones,

All of this and much more can certainly be done, but your question is
too broad, and requires too lengthy a reply to be answered in the NG's.
And, sorry, no magic wands either... it will take quite some time if you
don't know where to start from, so if you're really pressed for time I'd
suggest you either look for a readily available tool to buy, if one
exists that covers your needs, or commission the job to an experienced
developer.

Sorry to disappoint you, but such is life!

Nikos
 
Reply With Quote
 
Guest
Posts: n/a
 
      27th Jun 2006
Thank you Sylvain -- I'd reposted my question (a few mins after this one)
breaking down the tasks. Here's what I need (to begin with):
=======================
I have the VBA code which will search the Directory Path and Import EXCEL
files into ACCESS. Here's what I need the code to do:

1. The existing code Imports the data in the entire EXCEL Workbooks -- I
need to be able to specify Certain Worksheets -- and then, only specified
Cells within these Worksheets -- what would be the best way to approach this
requirement?

Here's the code I have:
========================================
Sub Import_From_Excel()
'Macro Loops through the specified directory (strPath)
'and imports ALL Excel files to specified table in the Access
'Database.

Const strPath As String = "C:\Temp\" 'Directory Path
Dim strFile As String 'Filename
Dim strFileList() As String 'File Array
Dim intFile As Integer 'File Number

'Loop through the folder & build file list
strFile = Dir(strPath & "*.xls")
While strFile <> ""
'add files to the list
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
'see if any files were found
If intFile = 0 Then
MsgBox "No files found"
Exit Sub
End If
'cycle through the list of files & import to Access
'creating a new table called MyTable
For intFile = 1 To UBound(strFileList)
DoCmd.TransferSpreadsheet acImport, , _
"NewTable", strPath & strFileList(intFile), True, "A1:J50"
'Check out the TransferSpreadsheet options in the Access
'Visual Basic Help file for a full description & list of
'optional settings
Next
MsgBox UBound(strFileList) & " Files were Imported"
End Sub

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:(E-Mail Removed)...
> The first thing to do would be to ask in a newsgroup about Excel like
> microsoft.public.excel.
>
> The second thing would be to split your problem in its basic parts and if
> necessary, ask each part (or question) into its appropriate newsgroup.
> For exemple, locating a file by making a full search of all disk drives
> and repertories has more to do with files and scripting technologies
> (search Google for Scripting.FileSystemObject) than with Excel or Access.
>
> --
> Sylvain Lafontaine, ing.
> MVP - Technologies Virtual-PC
> E-mail: http://cerbermail.com/?QugbLEWINF
>
>
> <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi everyone. I am a VBAby that needs to learn fast, so any help is truly
>> appreciated. My first problem is to write a program that accepts user
>> input, say a file name from a form or even a cell in Excel, locates the
>> file (even if it's in another directory), extracts data from the file
>> based on a given range name (more user input) and prints the data to an
>> output line contained in the same sheet/form as the input. Can all this
>> be done? Can any of it? Any help to get me started will be most welcome!
>>

>
>



 
Reply With Quote
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      27th Jun 2006
Using DoCmd.TransferSpreadsheet is one of many method to import data from an
Excel spreadsheet. You can also use a linked table, the OLEDB driver for
Excel or Automation or whatever else. You will get more info by making a
search with Google or asking in a newsgroup about Excel.

Personally, I know near to nothing about Excel.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


<(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Thank you Sylvain -- I'd reposted my question (a few mins after this one)
> breaking down the tasks. Here's what I need (to begin with):
> =======================
> I have the VBA code which will search the Directory Path and Import EXCEL
> files into ACCESS. Here's what I need the code to do:
>
> 1. The existing code Imports the data in the entire EXCEL Workbooks -- I
> need to be able to specify Certain Worksheets -- and then, only specified
> Cells within these Worksheets -- what would be the best way to approach
> this
> requirement?
>
> Here's the code I have:
> ========================================
> Sub Import_From_Excel()
> 'Macro Loops through the specified directory (strPath)
> 'and imports ALL Excel files to specified table in the Access
> 'Database.
>
> Const strPath As String = "C:\Temp\" 'Directory Path
> Dim strFile As String 'Filename
> Dim strFileList() As String 'File Array
> Dim intFile As Integer 'File Number
>
> 'Loop through the folder & build file list
> strFile = Dir(strPath & "*.xls")
> While strFile <> ""
> 'add files to the list
> intFile = intFile + 1
> ReDim Preserve strFileList(1 To intFile)
> strFileList(intFile) = strFile
> strFile = Dir()
> Wend
> 'see if any files were found
> If intFile = 0 Then
> MsgBox "No files found"
> Exit Sub
> End If
> 'cycle through the list of files & import to Access
> 'creating a new table called MyTable
> For intFile = 1 To UBound(strFileList)
> DoCmd.TransferSpreadsheet acImport, , _
> "NewTable", strPath & strFileList(intFile), True, "A1:J50"
> 'Check out the TransferSpreadsheet options in the Access
> 'Visual Basic Help file for a full description & list of
> 'optional settings
> Next
> MsgBox UBound(strFileList) & " Files were Imported"
> End Sub
>
> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
> wrote in message news:(E-Mail Removed)...
>> The first thing to do would be to ask in a newsgroup about Excel like
>> microsoft.public.excel.
>>
>> The second thing would be to split your problem in its basic parts and if
>> necessary, ask each part (or question) into its appropriate newsgroup.
>> For exemple, locating a file by making a full search of all disk drives
>> and repertories has more to do with files and scripting technologies
>> (search Google for Scripting.FileSystemObject) than with Excel or Access.
>>
>> --
>> Sylvain Lafontaine, ing.
>> MVP - Technologies Virtual-PC
>> E-mail: http://cerbermail.com/?QugbLEWINF
>>
>>
>> <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Hi everyone. I am a VBAby that needs to learn fast, so any help is truly
>>> appreciated. My first problem is to write a program that accepts user
>>> input, say a file name from a form or even a cell in Excel, locates the
>>> file (even if it's in another directory), extracts data from the file
>>> based on a given range name (more user input) and prints the data to an
>>> output line contained in the same sheet/form as the input. Can all this
>>> be done? Can any of it? Any help to get me started will be most welcome!
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
search via user input on form =?Utf-8?B?VGhlUmFmdGVyTWFu?= Microsoft Access Forms 6 23rd Jul 2007 03:51 PM
counter on report/search via user input on form =?Utf-8?B?VGhlUmFmdGVyTWFu?= Microsoft Access 4 19th Jul 2007 03:20 PM
How can I search a table with text input from a user on a form? =?Utf-8?B?Q2hyaXM=?= Microsoft Access Forms 3 24th Apr 2006 07:53 PM
format cell from data input to output form Brad Stevenson Microsoft Excel Worksheet Functions 2 19th May 2005 06:04 PM
Excel VBA- Get user input, search the for match, output to text file gnileo Microsoft Excel Programming 1 8th Jan 2004 07:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:28 PM.