+ Reply to Thread
Results 1 to 2 of 2

VBA to Import all pictures in same filepath

Hybrid View

  1. #1
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    VBA to Import all pictures in same filepath

    Hi All,
    I'm attempting to write macro to that will include programming to import all photos (jpegs in this instance) that are in the same folder that presentation that includes the macro is stored and place each photo on a new slide. I'm currently stuch at the photo import portion and was wondering if anyone could hep me out. Here is what I have so far:

    Option Explicit
    Sub PresentationFormat()
    ' Description: This macro is designed to apply a standard size and center position to all
    ' existing pictures and a uniform Title across all slides
    ' Next steps are to add syntax to insert all pictures from same folder, one on each slide
    ' Changes----------------------------------------------
    ' Date:      Programmer:      Contact Info:  Change:
    '
    '
    ' =======================================================
    On Error GoTo ErrorHandler
    
    Dim oSld As Slide
    Dim oShp As Shape
    Dim x As Integer
    Dim y As Integer
    Dim strTitle As String
    Dim filepath As String
     
    ActiveWindow.View.GotoSlide 1 ' Change slide index position to the first slide
    
    
    filepath = ActivePresentation.Path & "\*.jpg" ' gets same filepath as presentation
    
    With ActivePresentation.PageSetup ' sets x and y parameters
     x = .SlideWidth / 2
     y = .SlideHeight / 2
    End With
    
    strTitle = InputBox("Please Enter A New Title") ' user enters title
    
    For Each oSld In ActivePresentation.Slides
     oSld.Shapes.Title.TextFrame.TextRange.Text = strTitle ' applies users title across all slides
    
    For Each oShp In oSld.Shapes ' all pictures in all slides
    
    If oShp.Type = msoPicture Then
     oShp.LockAspectRatio = False ' allows resizing
     oShp.Height = 329.76 ' set in pixels
     oShp.Width = 473.76 ' set in pixels
     oShp.Left = x - (oShp.Width / 2) ' centers horizontaly
     oShp.Top = y - (oShp.Height / 2) ' centers vertically
     oShp.Shadow.Visible = msoTrue ' shadow border
    
    End If
    
    Next
    Next
    
    NormalExit:
     Exit Sub
    ErrorHandler:
     MsgBox ("Oops, there's an error. Please call me!")
     Resume NormalExit:
    
    End Sub
    Any help would be greatly appreciated, thanks!

  2. #2
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: VBA to Import all pictures in same filepath

    Bumping along.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copying files from a selected filepath to a filepath mentioned in a worksheet's cell
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 03:59 PM
  2. UserForm, ListBox, FilePath, Import and Export HELP!
    By duncanm82 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2012, 01:18 AM
  3. Import Automatically Pictures
    By leturc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2012, 06:11 AM
  4. UNC filepath in Text file import VBA
    By Will31 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2010, 10:29 PM
  5. Import pictures from the web
    By Shatin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2005, 04:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1