Can anyone tell me the best way to do suppress all warnings when saving a file programatically?
I'd like to suppress all warning dialogs.
I've set "application.displayalerts" to false, but I've got a dialog that still pops up which halts code execution.
The nature of this program is that it will update ALL the excel files on our server, so it needs to run when nobody else is on the server as it creates a lot of traffic opening and saving files.
Since there is nobody there to click "ok" when the dialog pops-up, the program never finishes
Here is the procedure that updates the files and saves the changes.
Interestingly, I found that just using the close method with "save changes" turned on wasn't working - it wasn't saving the changes. So I found I had to force it to save using the save method.
(the application.displayalerts setting is set in the calling procedure)
I'd like to suppress all warning dialogs.
I've set "application.displayalerts" to false, but I've got a dialog that still pops up which halts code execution.
The nature of this program is that it will update ALL the excel files on our server, so it needs to run when nobody else is on the server as it creates a lot of traffic opening and saving files.
Since there is nobody there to click "ok" when the dialog pops-up, the program never finishes
Here is the procedure that updates the files and saves the changes.
Interestingly, I found that just using the close method with "save changes" turned on wasn't working - it wasn't saving the changes. So I found I had to force it to save using the save method.
(the application.displayalerts setting is set in the calling procedure)
Code:
Private Function UpdateLinks(strPATH As String) As Boolean
Dim lnkX As Excel.Hyperlink
Dim wshX As Excel.Worksheet
Dim wbkX As Excel.Workbook
Dim lngH As Long
UpdateLinks = False
Application.StatusBar = "Updating file: " & strPATH & "..."
On Error Resume Next
Set wbkX = Excel.Application.Workbooks.Open(strPATH, 3, False, , , , True, , , , False, , False, True, xlNormalLoad)
On Error GoTo 0
If Not wbkX Is Nothing Then
For Each wshX In wbkX.Worksheets
lngH = 0
lngH = wshX.Hyperlinks.Count
If lngH > 0 Then
UpdateLinks = True
For Each lnkX In wshX.Hyperlinks
lnkX.Address = Replace(lnkX.Address, "\\oldserver\oldshare\", "\\newserver\newshare\")
Next lnkX
End If
wshX.Cells.Replace What:="\\oldserver\oldshare\", Replacement:="\\newserver\newshare\", MatchCase:=False, lookat:=xlPart
Next
wbkX.Save
wbkX.Close
UpdateLinks = True
End If
End Function