View Full Version : Adjust Print Settings
areisett
08-28-2013, 02:38 PM
I'm trying to adjust the default print settings of my powerpoint so that it only prints the first ~100 slides. "NoDup_Count" is a public variable that counts the number of slides. I found most of the code in online help forums, but I keep getting the error "with object must be user defined type, object, or variant" on the first line. Any ideas how I can get my code to run? Thanks.
Sub Print_Settings()
With ActivePresentation.PrintOptions.RangeType = ppPrintSlideRange
With .Ranges
.ClearAll
.add1 , NoDup_Count
End With
End With
End Sub
John Wilson
08-28-2013, 11:28 PM
You cannot use with if it does not refer to an object or type
ActivePresentation.PrintOptions.RangeType=ppPrintSlideRange is not an object.
Sub Print_Settings()
Dim noDup_Count As Long
noDup_Count = ActivePresentation.Slides.Count
If noDup_Count > 100 Then noDup_Count = 100
With ActivePresentation.PrintOptions
.RangeType = ppPrintSlideRange
With .Ranges
.ClearAll
.Add 1, noDup_Count
End With
End With
End Sub
Note this is only going to set the options for this presentation.
areisett
08-29-2013, 06:57 AM
I modified the code slightly and it still didn't work. The following code gave me the error message "Object variable or with block variable not set". What I'm trying to do is count the number of slides in one presentation without duplicate slides (pres_ToCopy) and then set the default printer settings to print that number of slides in another presentation (pres). Any ideas as to how I can make this work? Thank you.
Sub Print_Settings()
Dim NoDup_Count As Long
NoDup_Count = pres_ToCopy.Slides.COUNT
With pres.PrintOptions
.RangeType = ppPrintSlideRange
With .Ranges
.ClearAll
.Add 1, NoDup_Count
End With
End With
End Sub
You cannot use with if it does not refer to an object or type
ActivePresentation.PrintOptions.RangeType=ppPrintSlideRange is not an object.
Sub Print_Settings()
Dim noDup_Count As Long
noDup_Count = ActivePresentation.Slides.Count
If noDup_Count > 100 Then noDup_Count = 100
With ActivePresentation.PrintOptions
.RangeType = ppPrintSlideRange
With .Ranges
.ClearAll
.Add 1, noDup_Count
End With
End With
End Sub
Note this is only going to set the options for this presentation.
John Wilson
08-29-2013, 07:32 AM
Maybe there's more code but you haven't declared or instantiated pres or pres_ToCopy
Did you test my code?
areisett
08-29-2013, 07:49 AM
I declared them in earlier code and have got it working, but the settings don't seem to stay once I save, close, and reopen the presentation. Any ideas?
John Wilson
08-29-2013, 12:50 PM
You need to post all of the code or a sample pptm
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.