PDA

View Full Version : Please help with VBA code PrintToFile



Vicky
02-19-2010, 10:07 AM
I've put together a slide show for training for work, but I can't turn it in because of one last glitch--I can't get the Completion Certificate to print to file. I found code on the web (maybe this site) that works to print a hard copy of the certificate; I need the slide to print to file to the desktop. I believe the path for that is
Dim Path = "c:\Documents and Settings\All Users\Desktop\" and that the file name will be the slide number.

This is the code I tried to modify


Sub PrintCurrentSlide()
' Get current slide number in the running show.

Dim SldNo As Long

Dim Pres As Presentation

SldNo = SlideShowWindows(1).View.Slide.SlideIndex

Set Pres = SlideShowWindows(1).Presentation

With Pres.PrintOptions

' Set the shaperange type to slides

.RangeType = ppPrintSlideRange

.NumberOfCopies = 1

.Collate = msoTrue

.OutputType = ppPrintOutputSlides

.PrintHiddenSlides = msoTrue

.PrintColorType = ppPrintBlackAndWhite

.FitToPage = msoFalse

.FrameSlides = msoFalse

' Clear existing ranges

.Ranges.ClearAll

' Set the print range to current slide

.Ranges.Add SldNo, SldNo

End With

Pres.PrintOut

Set Pres = Nothing

End Sub

Paul_Hossler
02-19-2010, 03:39 PM
Dim Path = "c:\Documents and Settings\All Users\Desktop\


1. No Dim, but I'm not seeing where you're using it
2. Print to "c:\Documents and Settings\Vicky\Desktop\

or what ever your logon in. That's the XP version, Vista and Win7 are a little different

See if that helps

Paul

John Wilson
02-20-2010, 07:35 AM
I'm not clear what you mean by Print to File. Save a ppt of the completion slide, save a jpeg or something else

Environ("USERPROFILE") & "\Desktop\" will give you the desktop in all versions if that helps. For both the above you would use the hidden method Export.

John Wilson
02-20-2010, 08:07 AM
Example

Sub File_Print_jpg()
Dim osld As Slide
Dim sngW As Single
Dim sngH As Single

sngH = ActivePresentation.PageSetup.SlideHeight
sngW = ActivePresentation.PageSetup.SlideWidth
Set osld = SlideShowWindows(1).View.Slide
osld.Export Environ("USERPROFILE") & "\Desktop\test.jpg" _
, "JPG", sngW, sngH
End Sub