Hey all =D Is there any way to suppress a read only dialogue (simply clicking "OK") that pops up on a macro run? I have a macro that imports data from a shared file, so when the macro is run it is normally open by other users. Clicking OK manually works and runs the required macro but I was wondering if there was a way to add the clicking OK in the macro itself?
Here's the macro
Sub ImportSheet()
Dim sImportFile As String, sFile As String
Dim sThisBk As Workbook
Dim vfilename As Variant
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set sThisBk = ActiveWorkbook
ChDrive "R:\" 'change the drive also
ChDir "\Public\Backorder Manifest\"
sImportFile = Application.GetOpenFilename( _
FileFilter:="Microsoft Excel Workbooks, *.xls; *.xlsx", Title:="Open Workbook")
If sImportFile = "False" Then
MsgBox "No File Selected!"
Exit Sub
Else
vfilename = Split(sImportFile, "\")
sFile = vfilename(UBound(vfilename))
Application.Workbooks.Open Filename:=sImportFile
Set wbBk = Workbooks(sFile)
With wbBk
If SheetExists("Manifest") Then
Set wsSht = .Sheets("Manifest")
wsSht.Copy After:=sThisBk.Sheets("Merge")
ActiveSheet.Name = "New2"
Else
MsgBox "There is no sheet with name :Raw_Data in:" & vbCr & .Name
End If
wbBk.Close SaveChanges:=False
End With
End If
Application.DisplayAlerts = True
End Sub
Private Function SheetExists(sWSName As String) As Boolean
Dim ws As Worksheet
On Error Resume Next
Set ws = Worksheets(sWSName)
If Not ws Is Nothing Then SheetExists = True
End Function
Bookmarks