run time error 1004

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
 
second test came back with this error
Document not saved, the document may be open, or an error may have been encountered when saving

The printer pop-up popped asking if i would like to print during the test also.

i checked the purchase_order folder and he has full permission to write to the folder
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
i checked the purchase_order folder and he has full permission to write to the folder
But were you able to run the test code I provided to successfully create a file in the "F:\purchase_orders\" folder named "Test.pdf"?
If so, after running the code, you should see that file in that folder.

This is one method to debug issues like this. Break them down into smaller tasks, and try running the VBA code with those tasks and see if you can do it, and continue to the point where you encounter the error. But you need to do it running the VBA code, otherwise you aren't really getting a true example of what you are trying to do. You can start at a higher level like we did, in checking some basic things. However if those all check out, then this is a good way of trying to find/isolate the problem (breaking your VBA code up into smaller sections).
 
Upvote 0
i still wasnt able to write to the F:\purchase_order\ folder running the test
OK, were you able to successfully write it to the C drive when you tried that, using the the test VBA code (test #1 in my previous description)?
 
Upvote 0
That seems to suggest that the user does not have the ability to write PDF files out from VBA using that code. May be because they are on a different version.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top