Consulting

Results 1 to 4 of 4

Thread: Please help with VBA code PrintToFile

  1. #1
    VBAX Newbie
    Joined
    Feb 2010
    Posts
    1
    Location

    Please help with VBA code PrintToFile

    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

    [VBA]
    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
    [/VBA]

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    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

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    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
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Example

    [VBA]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
    [/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •