ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FileDialog deactivating the close button (https://www.excelbanter.com/excel-programming/381940-filedialog-deactivating-close-button.html)

Fredriksson via OfficeKB.com

FileDialog deactivating the close button
 
When the user is selecting a file to open, I want to deactivate the X (Close
Button) so the user can not exit out of the macro.

Do you know if this can be done?


With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Text files", "*.den"
If .Show = True Then
Txt = .SelectedItems(1)
'Import data
For x = LBound(ColumnsDesired) To UBound(ColumnsDesired)
ColumnArray(x, 1) = ColumnsDesired(x)
ColumnArray(x, 2) = DataTypeArray(x)
Next x

Workbooks.OpenText Filename:=Txt, _
DataType:=xlFixedWidth, FieldInfo:=ColumnArray
ActiveSheet.UsedRange.Copy Destination:=Isheet.Range("A1")
ActiveWorkbook.Close SaveChanges:=False
End If
End With

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200701/1


Susan

FileDialog deactivating the close button
 
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button to close the form", vbInformation

End If
End Sub
xxxxxxxxxxxxxxxxx
susan


On Jan 25, 3:45 pm, "Fredriksson via OfficeKB.com" <u27002@uwe wrote:
When the user is selecting a file to open, I want to deactivate the X (Close
Button) so the user can not exit out of the macro.

Do you know if this can be done?

With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Text files", "*.den"
If .Show = True Then
Txt = .SelectedItems(1)
'Import data
For x = LBound(ColumnsDesired) To UBound(ColumnsDesired)
ColumnArray(x, 1) = ColumnsDesired(x)
ColumnArray(x, 2) = DataTypeArray(x)
Next x

Workbooks.OpenText Filename:=Txt, _
DataType:=xlFixedWidth, FieldInfo:=ColumnArray
ActiveSheet.UsedRange.Copy Destination:=Isheet.Range("A1")
ActiveWorkbook.Close SaveChanges:=False
End If
End With

--
Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200701/1



Susan

FileDialog deactivating the close button
 
whoops - i misread your post - that will disable the X on a userform -
don't know if it will work for the worksheet itself.....
sorry
susan

On Jan 25, 3:45 pm, "Fredriksson via OfficeKB.com" <u27002@uwe wrote:
When the user is selecting a file to open, I want to deactivate the X (Close
Button) so the user can not exit out of the macro.

Do you know if this can be done?

With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Text files", "*.den"
If .Show = True Then
Txt = .SelectedItems(1)
'Import data
For x = LBound(ColumnsDesired) To UBound(ColumnsDesired)
ColumnArray(x, 1) = ColumnsDesired(x)
ColumnArray(x, 2) = DataTypeArray(x)
Next x

Workbooks.OpenText Filename:=Txt, _
DataType:=xlFixedWidth, FieldInfo:=ColumnArray
ActiveSheet.UsedRange.Copy Destination:=Isheet.Range("A1")
ActiveWorkbook.Close SaveChanges:=False
End If
End With

--
Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200701/1



Jim Cone

FileDialog deactivating the close button
 
Directly above "End If" add...

Else
'Code to keep the macro going
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

"Fredriksson via OfficeKB.com"
<u27002@uwe
wrote in message
When the user is selecting a file to open, I want to deactivate the X (Close
Button) so the user can not exit out of the macro.

Do you know if this can be done?


With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Text files", "*.den"
If .Show = True Then
Txt = .SelectedItems(1)
'Import data
For x = LBound(ColumnsDesired) To UBound(ColumnsDesired)
ColumnArray(x, 1) = ColumnsDesired(x)
ColumnArray(x, 2) = DataTypeArray(x)
Next x

Workbooks.OpenText Filename:=Txt, _
DataType:=xlFixedWidth, FieldInfo:=ColumnArray
ActiveSheet.UsedRange.Copy Destination:=Isheet.Range("A1")
ActiveWorkbook.Close SaveChanges:=False
End If
End With

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200701/1



All times are GMT +1. The time now is 09:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com