VBA Excel close Word. Word Clipboard Question

ehel

New Member
Joined
Oct 13, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi.

I use this code in Excel vba:

VBA Code:
Dim wdApp As Word.Application


wdApp.Documents.Open "E:\Download\planeringsmote.doc"
wdApp.Documents(1).InlineShapes(2).Range.Copy
    wdApp.Documents.Close

    wdApp.Quit

The problem is that Word don't close because Word popup a messagesbox that ask if you want to save the stuff in the clipboard. This popup will not be seen by the user until the user click the Word icon in the taskbar.

Is there a way to force Word to close and skip all warnings and popups?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi,​
see on Word side what are the options of the property DisplayAlerts in its VBA help …​
 
Upvote 0
Maybe...
Code:
WdApp.DisplayAlerts = False
Maybe this might be useful too...
Code:
WdApp.ActiveDocument.Close savechanges:=False
HTH. Dave
 
Upvote 0
Solution
Maybe...
Code:
WdApp.DisplayAlerts = False
Maybe this might be useful too...
Code:
WdApp.ActiveDocument.Close savechanges:=False
HTH. Dave
Thanks. The final solution was to clear the clipboard too.

VBA Code:
Dim oData   As New DataObject 'object to use the clipboard
    oData.SetText Text:=Empty 'Clear
    oData.PutInClipboard 'take in the clipboard to empty it
    
    wdApp.ActiveDocument.Close savechanges:=False
    
    
    wdApp.Quit
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top