paintfrk775
New Member
- Joined
- Mar 2, 2016
- Messages
- 8
Hello all ,
I have been having this issue on one computer, every time i go print using the macro i get a run time 1004.
The other computers i run the macro on works with no issues.
i have attached my code to see if i missing something please let me know if there is any solutions or any issues with my code.
' this code sits in this workbook
' it adds plus one from the last time it saves
Private Sub Workbook_Open()
Range("j1").Value = Range("j1").Value + 1
Range("j1").Font.Color = vbRed
End Sub
Sub Submit_info()
'
' Will save P.O. template save as new P.O. print make into PDF and close
'
Dim strFilename As String
Dim strpath As String
Application.DisplayAlerts = False
strpath = "f:\purchase_orders\"
strFilename = Range("j1").Value
ActiveWorkbook.Save
'Remove all code from ThisWorkbook code module
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.DeleteLines 1, _
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.CountOfLines
'will create PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strpath & strFilename, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
'will print out white copy
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
'will save as with p.o. #
ActiveWorkbook.SaveAs strpath & strFilename, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
'Will write out yellow
ActiveSheet.Unprotect
ActiveSheet.Shapes.AddTextEffect(msoTextEffect3, "Your text here", "+mn-lt", 54 _
, msoFalse, msoFalse, 339.0575590551, 160.7104724409).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "-YELLOW-"
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 8). _
ParagraphFormat
.FirstLineIndent = 0
.Alignment = msoAlignCenter
End With
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 8).Font
.Bold = msoFalse
.Caps = msoNoCaps
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Shadow.Type = msoShadow21
.Shadow.Visible = msoTrue
.Shadow.Style = msoShadowStyleOuterShadow
.Shadow.Blur = 5
.Shadow.OffsetX = 0
.Shadow.OffsetY = 0
.Shadow.RotateWithShape = msoFalse
.Shadow.ForeColor.RGB = RGB(0, 0, 0)
.Shadow.Transparency = 0.3000000119
.Shadow.Size = 100
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Fill.Transparency = 0
.Fill.Solid
.Size = 54
.Line.Visible = msoTrue
.Line.ForeColor.RGB = RGB(255, 255, 255)
.Line.Transparency = 0
.Line.Weight = 1.45
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Name = "+mn-lt"
.Spacing = 0
End With
Selection.ShapeRange.IncrementLeft -154.5
Selection.ShapeRange.IncrementTop 16.5
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Selection.Delete
'will write out pink
ActiveSheet.Shapes.AddTextEffect(msoTextEffect3, "Your text here", "+mn-lt", 54 _
, msoFalse, msoFalse, 339.0575590551, 160.7104724409).Select
Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 96
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "-PINK-"
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 6). _
ParagraphFormat
.FirstLineIndent = 0
.Alignment = msoAlignCenter
End With
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 6).Font
.Bold = msoFalse
.Caps = msoNoCaps
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Shadow.Type = msoShadow21
.Shadow.Visible = msoTrue
.Shadow.Style = msoShadowStyleOuterShadow
.Shadow.Blur = 5
.Shadow.OffsetX = 0
.Shadow.OffsetY = 0
.Shadow.RotateWithShape = msoFalse
.Shadow.ForeColor.RGB = RGB(0, 0, 0)
.Shadow.Transparency = 0.3000000119
.Shadow.Size = 100
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Fill.Transparency = 0
.Fill.Solid
.Size = 96
.Line.Visible = msoTrue
.Line.ForeColor.RGB = RGB(255, 255, 255)
.Line.Transparency = 0
.Line.Weight = 1.45
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Name = "+mn-lt"
.Spacing = 0
End With
Selection.ShapeRange.IncrementRotation 312.6789166667
Selection.ShapeRange.IncrementLeft -231.7500787402
Selection.ShapeRange.IncrementTop 135.75
ActiveWindow.SmallScroll Down:=6
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Selection.Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True
'will close work book
ActiveWorkbook.Close True
End Sub
I have been having this issue on one computer, every time i go print using the macro i get a run time 1004.
The other computers i run the macro on works with no issues.
i have attached my code to see if i missing something please let me know if there is any solutions or any issues with my code.
' this code sits in this workbook
' it adds plus one from the last time it saves
Private Sub Workbook_Open()
Range("j1").Value = Range("j1").Value + 1
Range("j1").Font.Color = vbRed
End Sub
Sub Submit_info()
'
' Will save P.O. template save as new P.O. print make into PDF and close
'
Dim strFilename As String
Dim strpath As String
Application.DisplayAlerts = False
strpath = "f:\purchase_orders\"
strFilename = Range("j1").Value
ActiveWorkbook.Save
'Remove all code from ThisWorkbook code module
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.DeleteLines 1, _
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.CountOfLines
'will create PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strpath & strFilename, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
'will print out white copy
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
'will save as with p.o. #
ActiveWorkbook.SaveAs strpath & strFilename, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
'Will write out yellow
ActiveSheet.Unprotect
ActiveSheet.Shapes.AddTextEffect(msoTextEffect3, "Your text here", "+mn-lt", 54 _
, msoFalse, msoFalse, 339.0575590551, 160.7104724409).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "-YELLOW-"
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 8). _
ParagraphFormat
.FirstLineIndent = 0
.Alignment = msoAlignCenter
End With
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 8).Font
.Bold = msoFalse
.Caps = msoNoCaps
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Shadow.Type = msoShadow21
.Shadow.Visible = msoTrue
.Shadow.Style = msoShadowStyleOuterShadow
.Shadow.Blur = 5
.Shadow.OffsetX = 0
.Shadow.OffsetY = 0
.Shadow.RotateWithShape = msoFalse
.Shadow.ForeColor.RGB = RGB(0, 0, 0)
.Shadow.Transparency = 0.3000000119
.Shadow.Size = 100
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Fill.Transparency = 0
.Fill.Solid
.Size = 54
.Line.Visible = msoTrue
.Line.ForeColor.RGB = RGB(255, 255, 255)
.Line.Transparency = 0
.Line.Weight = 1.45
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Name = "+mn-lt"
.Spacing = 0
End With
Selection.ShapeRange.IncrementLeft -154.5
Selection.ShapeRange.IncrementTop 16.5
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Selection.Delete
'will write out pink
ActiveSheet.Shapes.AddTextEffect(msoTextEffect3, "Your text here", "+mn-lt", 54 _
, msoFalse, msoFalse, 339.0575590551, 160.7104724409).Select
Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 96
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "-PINK-"
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 6). _
ParagraphFormat
.FirstLineIndent = 0
.Alignment = msoAlignCenter
End With
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 6).Font
.Bold = msoFalse
.Caps = msoNoCaps
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Shadow.Type = msoShadow21
.Shadow.Visible = msoTrue
.Shadow.Style = msoShadowStyleOuterShadow
.Shadow.Blur = 5
.Shadow.OffsetX = 0
.Shadow.OffsetY = 0
.Shadow.RotateWithShape = msoFalse
.Shadow.ForeColor.RGB = RGB(0, 0, 0)
.Shadow.Transparency = 0.3000000119
.Shadow.Size = 100
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Fill.Transparency = 0
.Fill.Solid
.Size = 96
.Line.Visible = msoTrue
.Line.ForeColor.RGB = RGB(255, 255, 255)
.Line.Transparency = 0
.Line.Weight = 1.45
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Name = "+mn-lt"
.Spacing = 0
End With
Selection.ShapeRange.IncrementRotation 312.6789166667
Selection.ShapeRange.IncrementLeft -231.7500787402
Selection.ShapeRange.IncrementTop 135.75
ActiveWindow.SmallScroll Down:=6
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Selection.Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True
'will close work book
ActiveWorkbook.Close True
End Sub