R
retseort
I have some code that I am pretty sure I got off this board or at leas
some of it. It creates a command box that continues the macro once
action is taken.
For some reason it jams at the following point in the code. WHY? Th
interesting thing is if I change the word stop to anything else it wil
work once then jam again. I am using excel 2000
'Sets the toolbar's name
.Name = "Stop"
Here is the entire code....
Sub CreatePauseToolbar()
Dim NewBar As Object
'Creates the toolbar, and sets a variable to easily forma
it
Set NewBar = CommandBars.Add
With NewBar
'Sets the toolbar's name
.Name = "Stop"
'Makes the toolbar visible
.Visible = True
'Adds a button to the toolbar
.Controls.Add Type:=msoControlButton
With .Controls(1)
'Sets the style of the button to text only
.Style = msoButtonCaption
'Sets the caption of the button
.Caption = "Continue"
'Assigns the macro PartTwo to the button
.OnAction = "PartTwo"
End With
End With
End Sub
Sub PartTwo()
'Deletes the Pause toolbar
CommandBars("Stop").Delete
Selection.Copy
Sheets.Add
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False
Columns("A:A").EntireColumn.AutoFit
Application.CutCopyMode = False
ChDir "C:\TEMP"
ActiveWorkbook.SaveAs Filename:="C:\TEMP\mailcost_load.prn"
FileFormat:= _
xlTextPrinter, CreateBackup:=False
Range("A1").Select
Columns("C:C").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.MergeCells = False
End With
Columns("A:A").Select
Columns("A:A").EntireColumn.AutoFit
Range("A1").Select
Cells.Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.MergeCells = False
End With
Range("A1").Select
ActiveWorkbook.SaveAs Filename:="C:\TEMP\mailcost_load.prn"
FileFormat:= _
xlTextPrinter, CreateBackup:=False
End Su
some of it. It creates a command box that continues the macro once
action is taken.
For some reason it jams at the following point in the code. WHY? Th
interesting thing is if I change the word stop to anything else it wil
work once then jam again. I am using excel 2000
'Sets the toolbar's name
.Name = "Stop"
Here is the entire code....
Sub CreatePauseToolbar()
Dim NewBar As Object
'Creates the toolbar, and sets a variable to easily forma
it
Set NewBar = CommandBars.Add
With NewBar
'Sets the toolbar's name
.Name = "Stop"
'Makes the toolbar visible
.Visible = True
'Adds a button to the toolbar
.Controls.Add Type:=msoControlButton
With .Controls(1)
'Sets the style of the button to text only
.Style = msoButtonCaption
'Sets the caption of the button
.Caption = "Continue"
'Assigns the macro PartTwo to the button
.OnAction = "PartTwo"
End With
End With
End Sub
Sub PartTwo()
'Deletes the Pause toolbar
CommandBars("Stop").Delete
Selection.Copy
Sheets.Add
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False
Columns("A:A").EntireColumn.AutoFit
Application.CutCopyMode = False
ChDir "C:\TEMP"
ActiveWorkbook.SaveAs Filename:="C:\TEMP\mailcost_load.prn"
FileFormat:= _
xlTextPrinter, CreateBackup:=False
Range("A1").Select
Columns("C:C").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.MergeCells = False
End With
Columns("A:A").Select
Columns("A:A").EntireColumn.AutoFit
Range("A1").Select
Cells.Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.MergeCells = False
End With
Range("A1").Select
ActiveWorkbook.SaveAs Filename:="C:\TEMP\mailcost_load.prn"
FileFormat:= _
xlTextPrinter, CreateBackup:=False
End Su