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.

VB: Application beenden

Empfohlene Antworten

Veröffentlicht

Hallo,

in folgendem Code werden ausgewählte Dokumente geöffnet und gedruckt..

Wie kann ich nun ein geöffnetes Dokument inkl. der Anwendung wieder schließen?

Private Sub Command1_Click()

Dim MyObject, i As Integer

For i = 1 To File.ListCount

File.ListIndex = i - 1

Set MyObject = GetObject(File.Path & "\" & File.FileName)

Set MyApp = MyObject.application

MyApp.Visible = True

MyApp.Printout

Next i

End Sub

Wäre nett, wenn Ihr mir helfen könntet.

Danke & Gruß,

chris;-)

also so wie ich das sehe einfach mit

MyApp.Close

Set MyApp = nothing

oder das ganze mit

MyObject

Sollte dann funktionieren.

Guido

Hi,

mit deiner Lösung wird zwar das Word-Dokument geschlossen, aber nicht Word selbst. Da Word aber nicht geschlossen wird, wird das nächste Dokument nicht richtig geöffnet.. Es wird dann nicht "Aktiv", und ich kann es nicht ausdrucken.

Jetzt müsste ich also noch wissen, wie ich:

-entweder Word richtig beende,

-oder wie ich das Dokument aktiviere, so dass ich drucken könnte.

Gruß,

Chris;-)

OK - ich schreib hier noch mal die Fehlermeldung hin, die er mir ausgibt:

Run-time error '4605':

This method or property is not available because a document window is not active.

Wie aktiviere ich das geöffnete Dokument?

Is wichtig

Wenn mir jemand via PM seine eMail-Adresse zukommen lässt, schicke ich ihm das Projekt als ZIP-File zu.

Danke, Chris

Hallo Chris,

versuch's mal mit

MyApp.Quit

bevor Du

Set MyApp = Nothing

setzt.

Ansonsten wäre es vielleicht ganz gut, vor dem Öffnen des Dokumentes abzufragen, ob Word schon geöffnet ist, bzw. ein Word-Objekt zu benutzen, z.B. so:

Dim WordObj As Word.Application

Und dann zum Prüfen, ob Word geöffnet ist:

' Ist Word geöffnet?

Set WordObj = GetObject(, "Word.Application")

' Wenn nicht

If Err = 429 Then

Set WordObj = New Word.Application

End If

Und zum Beenden:

WordObj.Quit

Set WordObj = Nothing

Bei Deiner Schleife mußt Du mal sehen. Ich habe jetzt nicht so viel Zeit, aber lass mich mal wissen, ob das geklappt hat. Mußt mal ein bißchen rumprobieren.

Viel Glück und LG,

Never :cool:

Oder als Code:

if MyWord is nothing then

set myword = new word.application

else

//hier brauchst du nix zu machen, hast dein Objekt ja schon, oder einfach das:

set myword = nothing

set myword = new word.application

end if

so hast du auf jeden Fall Word als neue Instanz. Bei den Office Anwendungen ist es wichtig, sie erst ordentlich zu beenden (App.quit, oder app.close) am Besten auch das aktuelle Document auch zu machen.

Dann noch ein "set xx = nothing" und dann müßte es gehen ...

M., der die Problem sehr gut kennt ;)

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.