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.

Bestehende Excel-Datei mit VB öffnen

Empfohlene Antworten

Veröffentlicht

Wie kann ich eine bestehende xls-Datei mit VB öffnen, so dass ich z.B. Werte aus einem Textfeld in die Datei einlesen kann?!

Hier der Quellcode - könnte vielleicht hilfreich sein.

Ich denke mal, der Knackpunkt liegt bei der Markierung

Private Sub CmdBerechne_Click()

' Deklarieren der Variablen

Dim m As Integer

Dim objExcel As Excel.Application

Dim objBook As Excel.Workbook

Dim objSheet As Excel.Worksheet

Set objExcel = objExcel.Workbooks.Open("d:\vb_test\monatsrechnung.xls")

'Set objBook = objExcel.Workbooks.Add

'Set objSheet = objExcel.Worksheets.Add

' Übertragen der Werte aus den Textfeldern

objSheet.Cells(3, 2) = Text1(0).Text

objSheet.Cells(5, 2) = Text1(1).Text

objSheet.Cells(6, 2) = Text1(2).Text

objSheet.Cells(10, 2) = Text1(3).Text

For m = 3 To 7

objSheet.Cells(m, 5) = Text1(m + 1).Text

Next

objExcel.Visible = True

End Sub

ist schon fast richtig.

versuch mal:

'**den Projekt Verweis nicht vergessen

Set objExcel = New Excel.Application

'** Datei öffnen

objExcel.Workbook.Open ("Monatsrechnung.xls")

'** dann das Tabellenblatt Aktivieren welches man bearbeiten will

objExcel.Sheets(1).Activate

und dann so weiter

am ende

objExcel.Workbook.Close

objExcel.Quit

set objExcel = Nothing

Gruß

Guido

PS: hab es jetzt aus dem Kopf gemacht. schick Dir morgen den Code aus meinem Projekt mal

so - das hätte ich jetzt :D

noch ne frage:

- wie beendet man über vb excel, so dass nicht nachgefragt wir ob man die tabelle speichern will?! ich weiss das geht, nur nicht wie!

habs bisher so probiert:

objExcel.Workbooks.Close

objExcel.Quit

Set objExcel = Nothing

greetz

dann must Du noch die Eigenschaft DisplayErrors oder so auf False setzten, dann geht es ohne Meldung

gracias

:P :p

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.