Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[VBA] Zellzugriff auf eine Exceldatei via VBA

Empfohlene Antworten

Veröffentlicht

Hi,

ich habe folgendes Problem. Ich möchte mittels VBA Daten aus meiner

Datenbank nach Excel exportieren. Da ich die Formatierung der Excel

Datei aber zeitgleich anpassen muss kann ich das nicht über die DoCmd.

TransferSpreadsheet - Methode machen.

Ich hab folgenden Code geschrieben:


Option Compare Database

Option Explicit


Public wkbXL1 As Workbook


Public Function export(sSQL As String, is_type As Integer)

Dim iZeile, iSpalte As Integer

Dim i, j, k As Integer

Dim sSQL_query As String


Set wkbXL1 = Workbooks.Add

With wkbXL1

    .application.Visible = True

    .Parent.Windows(1).Visible = True

End With


iZeile = 1


sSQL_query = sSQL

Call mdl_database.createSQLRecordset(sSQL_query)


While rs.EOF = False

 wkbXL1.Sheets(1).Cells(iZeile, 0) = Trim(rs.Fields(0).Value)

 iZeile = iZeile + 1

 rs.MoveNext

Wend

End Function

Bei wkbXL1.Sheets(1).Cells(iZeile,0) = trim(rs.fields(0).value) bringt

er folgende Fehlermeldung:

Laufzeitfehler '1004':

Anwendungs- oder objektdefinierter Fehler

Kann mir einer sagen, warum Access diese Fehlermeldung bringt oder

ob ich etwas falsch mache? Und wenn ja was???!!!??!

Danke und Gruß

Druid :cool:

Hi Druid,

versuch´s mal mit der Zeile.

wkbXL1.Sheets(1).Cells(iZeile,0).value = trim(rs.fields(0).value)

Viele Grüße

Stefan_1

Hi,

danke, aber daran lag es nicht. Ich habe es gelöst. Und zwar benennt die

1 in der Klammer bei wkbXL1.Sheets(1) das Tabellenblatt. Bei mir heißen

die Dinger aber nicht 1,2,3,.. sondern "Tabelle1", "Tabelle2",...

also muss der Befehl richtig lauten:

wkbXL1.Sheets("Tabelle1").Cells(iZeile,0) = trim(rs.fields(0).value)

für alle, die das gleiche Problem haben :eek:

Greetz

Druid :cool:

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.