Re: Importing Excel



If you're using Access 97, you won't have that function. Try replacing it with this ...

Function LastInStr(strSearched As String, strSought As String) As Integer
On Error Resume Next

'//////////////////////////////////////////////////////////////////////////
'
' This function finds the last instance of a character within
' a string of characters and returns an integer representing
' the final position of the desired character.
'
' Typically, this function us used to find the final "\" in
' a file path string
'
'//////////////////////////////////////////////////////////////////////////

Dim intCurrVal As Integer
Dim intLastPosition As Integer

intCurrVal = InStr(strSearched, strSought)
Do Until intCurrVal = 0
intLastPosition = intCurrVal
intCurrVal = InStr(intLastPosition + 1, strSearched, strSought)
Loop
LastInStr = intLastPosition

End Function



--

Danny J. Lesandrini
dlesandrini@xxxxxxxxxxx
http://amazecreations.com/datafast/



"Brian Graham" <GrahamB@xxxxxxxxxxxxx> wrote in message news:iqIRe.7421$884.731826@xxxxxxxxxxxxxxxxxxxxxxxx
> Thanks, Danny! Its always the obvious that's overlooked, isn't it? References are something I've managed to avoid,
> despite working on fairly significant apps for several years now. But there're always previously unused capabilities
> to learn about..
>
> Selecting the reference as you indicated got me past the first error. Now I'm getting an undefined variable InStrRev
> in ProcessInputFile, but I've just DL'd the zip file. We'll see how we fare from here.
>
> Thanks again!
> --
> Brian
>
>>>> Danny J. Lesandrini<dlesandrini@xxxxxxxxxxx> September 1, 2005 2:35 pm >>>
> Sorry about that. Didn't realize you haven't set references yet. You
> will become very familiar with this in time.
>
> Open any code module and select References from the Tools menu.
> A dialog box will appear with some items checked (selected) at the
> top of the list. Leave those alone and scroll down until you find one
> named Microsoft Excel and select (check) the box. Save and close
>
> Now, Choose Compile from the Debug menu and see if it throws any
> errors.
>
> To test my code, press Ctl+G to display the IMMEDIATE window and
> type the following into the window ...
>
> ? ProcessFileImport ("C:\download\sales.xls","sales_import")
>
> The Question Mark is shorthand for "Please print the result." It's
> followed by the name of the procedure and it's arguments. The
> first arg is the file path and name. The second is the name of the
> table into which you are importing the data in the file.
>
> My code is designed for my table and file. If you want to import
> your own, you'll need to modify some things. It's not trivial, but
> you can figure it out. Just follow the example for the sales table
> and make the appropriate entries in table: ImportColumnSpecs.
>
> Good luck
> --
>
> Danny J. Lesandrini
> dlesandrini@xxxxxxxxxxx
> http://amazecreations.com/datafast/
>
>
>
> "Brian Graham" <GrahamB@xxxxxxxxxxxxx> wrote in message news:x5HRe.8969$2F1.523385@xxxxxxxxxxxxxxxxxxxxxxxx
>>I wish I knew how... ??
>>
>>>>> Danny J. Lesandrini<dlesandrini@xxxxxxxxxxx> September 1, 2005 1:07 pm >>>
>> You need to set a reference to Excel. It doesn't matter which version you have, but the reference has to be set. Do
>> that and try compiling the code again.
>>
>> "Brian Graham" <GrahamB@xxxxxxxxxxxxx> wrote in message
>>
>>> I'm trying to automate the import of an Excel spread*** into Access. Something I've never done before.
>>> However, when I invoke the code, the function bombs on bad keywords. Excel.Application Excel.Workbook &
>>> Excel.Work***
>
>
>
>


.


Loading