0
我正在從Excel打開文件的過程。我想插入一個檢查,如果用戶按下打開沒有選擇一個文件,然後有消息框彈出警告。OpenFileDialog - 檢查是否未選擇
這是我的代碼的一部分,我想插入檢查。我嘗試使用Is Nothing
,但它不適合我。
If GetOpenFileName.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
fileStream = GetOpenFileName.OpenFile()
If (fileStream Is Nothing) Then 'I tried checking here, but it does not fire.
vmbContinue = MsgBox(strAlert, MsgBoxStyle.RetryCancel + MsgBoxStyle.Critical, "No Workbook Seletected")
If vmbContinue = MsgBoxResult.Cancel Then
xlWB.Close(SaveChanges:=False)
Exit Sub