Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deactivating a macro button Victor Delta[_2_] Excel Discussion (Misc queries) 2 November 8th 09 02:07 PM
Deactivating a Forms macro button based on a worksheet condition? Ace70 Excel Discussion (Misc queries) 3 June 10th 07 10:31 PM
Don't let user close. Use macro button to close? mike Excel Programming 2 October 30th 06 01:31 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"