application.displayalerts is not working

W

will lam

hi

i got a VBA prog. to open excel. but, when the prog. open excel spreadsheet, there is an error. "Can't open pivot table soubrce file..." so, i tried to supress the error message via the code. but, VB stops at the Open() statement, and wait for me to respond to the message before it continues. and, i really want VB ignores the error, and continues

Application.DisplayAlerts = wdAlertsNon

TempFileString = sfilePath & "\" & TempFileStrin
Set owb = oXL.Workbooks.Open(FileName:=TempFileString, UpdateLinks:=False, ReadOnly:=False, ignoreReadOnlyRecommended:=True

Application.DisplayAlerts = wdAlertsAl

does anyone has any idea on how to resolve this problem

thank a lot

will :O
 
J

Juan Pablo Gonzalez

The message is coming from Excel, not Word... try this:

oXL.DisplayAlerts = False

'your code here...

oXL.DisplayAlerts = True

--
Regards,

Juan Pablo González

will lam said:
hi,

i got a VBA prog. to open excel. but, when the prog. open excel
spreadsheet, there is an error. "Can't open pivot table soubrce file..." so,
i tried to supress the error message via the code. but, VB stops at the
Open() statement, and wait for me to respond to the message before it
continues. and, i really want VB ignores the error, and continues.
Application.DisplayAlerts = wdAlertsNone

TempFileString = sfilePath & "\" & TempFileString
Set owb = oXL.Workbooks.Open(FileName:=TempFileString,
UpdateLinks:=False, ReadOnly:=False, ignoreReadOnlyRecommended:=True)
 
W

will lam

thank you

the oXL.DisplayAlerts = False does supress the error message IF i press F8 in VB editor to step through the code. but, if i set a breakpoint and hit F5. then, the error message comes up again

does anyone has any idea on that

thank you

will lam

Set oXL = New Excel.Applicatio

'wla
oXL.DisplayAlerts = Fals

TempFileString = sFileStrin
sTempTicker = Left(sFileString, Len(sFileString) - 4
On Error GoTo bai


TempFileString = sfilePath & "\" & TempFileStrin
Set owb = oXL.Workbooks.Open(FileName:=TempFileString, UpdateLinks:=False, ReadOnly:=False, ignoreReadOnlyRecommended:=True


Set oSht = owb.Worksheets.Item("Cover Page"

sAnalystEmail = Trim(oSht.Cells(9, 4).Value
If Not InStr(sAnalystEmail, "@") > 0 The
PrepExcelFile = CStr(GetAnalystIDFromTicker(sTempTicker)
If PrepExcelFile = "" Then GoTo NoAnalys
Els
PrepExcelFile = GetAnalystIDFromDB(sAnalystEmail
If PrepExcelFile = "" Then GoTo NoAnalys
End I

For Each oWs In owb.Worksheet
oWs.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=Tru
Nex

For Each oChart In owb.Chart
oChart.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=Tru
Nex


-> breakpoint here: bProtected = ProtectedCheck(owb
 
Top