+ Reply to Thread
Results 1 to 3 of 3

How do I stop the "do you want to save changes" prompt using VB code

  1. #1
    Registered User
    Join Date
    02-09-2005
    Posts
    12

    How do I stop the "do you want to save changes" prompt using VB code

    Hi,

    I have a problem with my VB code, which is shown as follows:

    __________________________________________

    Private Sub This_WorkbookOpen()

    '
    ' Macro1 Macro
    ' Macro recorded 13/02/2005 by Jonathon White
    '

    '
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;C:\phpdev\www\website\database\shareasale2.csv", Destination:=Range( _
    "A1"))
    .Name = "shareasale2"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = xlWindows
    .TextFileStartRow = 1
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = False
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileOtherDelimiter = "|"
    .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
    .Refresh BackgroundQuery:=False
    End With
    Columns("A:A").Select
    Selection.Delete Shift:=xlToLeft
    Columns("B:B").Select
    Selection.Delete Shift:=xlToLeft
    Columns("B:C").Select
    Selection.Cut
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight
    ActiveWindow.SmallScroll ToRight:=3
    Columns("E:E").Select
    ActiveWindow.SmallScroll ToRight:=1
    Selection.Delete Shift:=xlToLeft
    Columns("F:F").Select
    Selection.Delete Shift:=xlToLeft
    Columns("H:H").Select
    Selection.Cut
    ActiveWindow.SmallScroll ToRight:=-2
    Columns("D:D").Select
    Selection.Insert Shift:=xlToRight
    ActiveWindow.SmallScroll ToRight:=1
    Columns("I:S").Select
    Selection.Delete Shift:=xlToLeft
    ActiveWindow.SmallScroll ToRight:=-1
    Range("I2").Select
    ActiveCell.FormulaR1C1 = "=RC[-2]&"" ""&RC[-1]"
    Range("I2").Select
    Selection.AutoFill Destination:=Range("I2:I47684"), Type:=xlFillDefault
    Range("I2:I47684").Select
    ActiveWindow.ScrollRow = 1
    ActiveWindow.SmallScroll ToRight:=1
    Columns("I:I").Select
    Selection.Copy
    Columns("M:M").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Columns("G:L").Select
    Range("L1").Activate
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    ActiveWindow.SmallScroll ToRight:=-1
    Columns("G:G").Select
    Selection.Cut
    Columns("F:F").Select
    Selection.Insert Shift:=xlToRight
    ActiveWindow.SmallScroll ToRight:=-4
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
    Range("A1").Select
    ChDir "C:\phpdev\www\website\database"
    ActiveWorkbook.SaveAs Filename:= _
    "C:\phpdev\www\website\database\shareasale7.txt", FileFormat:=xlText, _
    CreateBackup:=False
    ThisWorkbook.Close
    Application.Close
    End Sub
    _____________________________________________


    When ever the code is launch, I get a prompt at the end saying "do you want to save the changes made to 'shareasale.xls'?

    How do I add that to my VB code above so that this prompt stops appearing?

    I hope that someone can help me as I have been trying to work this out for a while now.

    Thanks!
    Last edited by john928; 02-13-2005 at 10:56 AM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867
    Good afternoon

    Use this somewhere near to the start of your code:

    Application.DisplayAlerts = False

    to turn them off and this at the end to turn them back on again.

    Application.DisplayAlerts = True

    HTH

  3. #3
    Registered User
    Join Date
    02-09-2005
    Posts
    12
    Thanks for that information.

+ 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