Re: Application.display alerrts and visible=false
This works for me to save it without the prompt
tip: run the saved and close event in a sub inside Word for it to work. It won't work from Excel.
ActiveDocument.Saved = True
Application.Quit
and, I am thinking, you have the visible=false in the wrong place
try something like this (no guarantees, but better than what you have got so far)
Sub Unload4_Click()
Dim rngMine As Range
Dim rngMine2 As Range
Dim wdApp As Word.Application
Dim myDoc As Word.Document
Dim mywdRange As Word.Range
Dim TableTemp As Table
Dim rngTemp As Range
Dim Loseall As Range
Dim rngMine3 As Range
Dim wdApp3 As Word.Application
Dim myDoc3 As Word.Document
Dim mywdRange3 As Word.Range
Dim rngTemp3 As Range
Dim Loseall3 As Range
On Error Resume Next
Set wdApp3 = New Word.Application
Set myDoc3 = wdApp3.Documents.Add
Set mywdRange3 = myDoc3.Words(1)
Set rngMine3 = ThisWorkbook.Worksheets("Fax").Range("Offforword3")
Set wdApp = New Word.Application
Set myDoc = wdApp.Documents.Add
Set mywdRange = myDoc.Words(1)
Set rngMine = ThisWorkbook.Worksheets("Calc").Range("offforword")
Set rngMine2 = ThisWorkbook.Worksheets("dum").Range("offforword2")
wdApp3.Visible = False
If ThisWorkbook.Worksheets("Calc").Range("a1001") = 0 Then
rngMine2.Copy
Else
rngMine.Copy
End If
With mywdRange
.PasteExcelTable False, False, False
.PageSetup.Orientation = wdOrientPortrait
.PageSetup.Gutter = 0#
.PageSetup.BottomMargin = 10
.PageSetup.LeftMargin = 15
.PageSetup.RightMargin = 10
.PageSetup.TopMargin = 10
.Application.DisplayAlerts = wdAlertsNone
myDoc.Saved = True
Set TableTemp = wdApp.ActiveDocument.Tables(1)
End With
Application.ScreenUpdating = True
With wdApp
.Application.DisplayAlerts = wdAlertsNone
myDoc.PrintOut
.Visible = False
myDoc.Saved = True
myDoc.Close
wdApp.Quit
End With
With wdApp3
.DisplayAlerts = wdAlertsNone
.Visible = False
End With
Application.ScreenUpdating = False
If ThisWorkbook.Worksheets("Calc").Range("a1001") > 0 Then
Set rngMine3 = ThisWorkbook.Worksheets("Fax").Range("Offforword3")
rngMine3.Copy
With mywdRange3
.PasteSpecial Link:=True, DataType:=wdPasteOLEObject, Placement _
:=wdInLine, DisplayAsIcon:=False
.PageSetup.Orientation = wdOrientPortrait
.PageSetup.Gutter = 0#
.PageSetup.BottomMargin = 10
.PageSetup.LeftMargin = 10
.PageSetup.RightMargin = 15
.PageSetup.TopMargin = 10
.Application.DisplayAlerts = wdAlertsNone
End With
Application.ScreenUpdating = True
With wdApp3.Visible = False
.Application.DisplayAlerts = wdAlertsNone
.Application.DisplayAlerts = False
myDoc3.PrintOut
End With
End If
Set wdApp3 = Nothing
Set myDoc3 = Nothing
Set mywdRange3 = Nothing
Set rngMine3 = Nothing
Set wdApp = Nothing
Set myDoc = Nothing
Set mywdRange = Nothing
Set rngMine = Nothing
Set TableTemp = Nothing
Set rngTemp = Nothing
End Sub
Display More