Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-05-2023, 02:29 PM
fops fops is offline Close inactive document Windows 10 Close inactive document Office 2019
Novice
Close inactive document
 
Join Date: Mar 2023
Posts: 6
fops is on a distinguished road
Default Close inactive document

Hi,


i want to close a document automatically. It works for an active doc which is in the foreground. When I open another doc and place the doc i want to get closed in the background, the doc will not close.

To close the doc i have:

Application.OnTime When:=Now + TimeValue("00:00:30"), Name:="CloseDoc"


In function CloseDoc() is have:


Sub CloseDoc()
'Documents("file.docm").Activate
'ThisDocument.Close SaveChanges:=wdSaveChanges

Dim wdApp As Word.Application
Set wdApp = GetObject(, "Word.Application")
wdApp.Documents("file.docm").Close SaveChanges:=wdSaveChanges
End Sub


I've also tried the uncommented statements in the Sub, but none of them did it.
Any hint to solve the prob?

Thank you in advance & greetings
fops
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to dectect if close document and now no document open skarden Word VBA 2 10-24-2022 07:03 AM
Close inactive document Close Document Without Saving Prompt Joe528 Word 3 10-08-2021 06:12 PM
Document close if/then/else error eduzs Word VBA 1 01-02-2021 05:56 AM
Save and Close powerpoint if it is inactive MetteGaga PowerPoint 0 04-16-2015 05:14 AM
Prompt when close the document ubns Word 15 04-29-2012 10:07 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft