Excel automatisch naar Access

Status
Niet open voor verdere reacties.

Semafoor

Gebruiker
Lid geworden
29 aug 2007
Berichten
129
Hallo iedereen,

Ik ben op dit moment bezig om logbestanden naar een excel bestand te kopieren. Datis inmiddels gelukt. http://www.helpmij.nl/forum/showthread.php?t=312727 Maar nu wil ik dat excel bestand Automatisch naar een acces bestand kopieren door middel van macro's. Hij kopieert alleen maar het eerste tabblad. Nu wil ik specifiek het tweede tabblad dat files heet kopiëren naar een andere tabbel. Is daar een macro voor of moet ik dat met een vba script doen?..

Bij voorbaat dank.

Stefan
 
hellaasDit

is niet echt wat ik bedoel.. Ik wil iets in Access zelf plaatsen waardoor het werkt.

Is dat ook mogelijk?
 
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:\Will\Link Files\" '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
 
Help..

Hoe kan ik een module laten starten ?

In een macro en dan: Moduleopenen?
 
Een module kun je niet starten.
Een module is gewoon een bak met routines (subs) en functies (functions).
Een sub kun je uitvoeren door de naam van de sub in te tikken op de juiste plaats in de code onder bijvoorbeeld een knop.
In de voorbeeldcode die ik je gegeven heb is de naam van de sub Import_From_Excel.

Een functie geeft een waarde terug die je elders weer kan gebruiken, die moet je dus aanroepen.
voorbeeld: Return = fnMijnFunctie(par1, par2).
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan