A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old June 27th, 2006, 01:51 PM posted to microsoft.public.access
external usenet poster
 
Posts: n/a
Default Can VBA take user input (form?), search and locate file, retreive data and output?

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!


  #2  
Old June 27th, 2006, 02:38 PM posted to microsoft.public.access
Sylvain Lafontaine
external usenet poster
 
Posts: 528
Default Can VBA take user input (form?), search and locate file, retreive data and output?

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


wrote in message
...
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!



  #3  
Old June 27th, 2006, 02:51 PM posted to microsoft.public.access
Nikos Yannacopoulos
external usenet poster
 
Posts: 33
Default Can VBA take user input (form?), search and locate file, retreivedata and output?

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
  #4  
Old June 27th, 2006, 03:26 PM posted to microsoft.public.access
external usenet poster
 
Posts: n/a
Default Can VBA take user input (form?), search and locate file, retreive data and output?

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 ...
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


wrote in message
...
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!





  #5  
Old June 27th, 2006, 03:45 PM posted to microsoft.public.access
Sylvain Lafontaine
external usenet poster
 
Posts: 528
Default Can VBA take user input (form?), search and locate file, retreive data and output?

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


wrote in message
...
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 ...
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


wrote in message
...
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!







 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:04 AM.


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