+ Reply to Thread
Results 1 to 2 of 2

Deactivate X (Close button) when using FileDialog

  1. #1
    Registered User
    Join Date
    09-22-2006
    Posts
    11

    Deactivate X (Close button) when using FileDialog

    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? Is there a property that needs to be set.

    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

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Fredriksson,

    Add a Standard Module to your VBA project and then copy and paste the code below into it. There's a lot of code, but the macro is very easy to use. Place the macro call before you call the dialog.

    Example:
    Call DisableCloseBox(250)
    Application.Dialogs(xlDialogOpen).Show


    The 250 is a time delay of 1/4 second (250 milliseconds). This has worked well for me. If you need to increase the time, you can.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1