+ Reply to Thread
Results 1 to 4 of 4

Inserting a Picture into Shape Quickly

Hybrid View

  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac 2011
    Posts
    11

    Inserting a Picture into Shape Quickly

    I am working with Excel for Mac 2011.

    In the SmartArt section they have a picture tab, where you can select from various formats. None of these formats fit my needs. So my question is, can I customize these?

    If not, can I add a macro to a shape so that it can do what the picture boxes do, opening the folder to select a photo, and put it into excel in the shape, location, and size of the shape?

  2. #2
    Registered User
    Join Date
    06-20-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac 2011
    Posts
    11

    Re: Inserting a Picture into Shape Quickly

    With this code from the microsoft website I was able to get the file selection to pop up but was not able to get a .gif or jpeg

    Any ideas on what I would need to change to make this possible?

    Sub Select_File_Or_Files_Mac()
        Dim MyPath As String
        Dim MyScript As String
        Dim MyFiles As String
        Dim MySplit As Variant
        Dim N As Long
        Dim Fname As String
        Dim mybook As Workbook
    
        On Error Resume Next
        MyPath = MacScript("return (path to documents folder) as String")
        'Or use MyPath = "Macintosh HD:Users:Ron:Desktop:TestFolder:"
    
        ' In the following statement, change true to false in the line "multiple 
        ' selections allowed true" if you do not want to be able to select more 
        ' than one file. Additionally, if you want to filter for multiple files, change 
        ' {""com.microsoft.Excel.xls""} to 
        ' {""com.microsoft.excel.xls"",""public.comma-separated-values-text""}
        ' if you want to filter on xls and csv files, for example.
        MyScript = _
        "set applescript's text item delimiters to "","" " & vbNewLine & _
                   "set theFiles to (choose file of type " & _
                 " {""com.microsoft.Excel.xls""} " & _
                   "with prompt ""Please select a file or files"" default location alias """ & _
                   MyPath & """ multiple selections allowed true) as string" & vbNewLine & _
                   "set applescript's text item delimiters to """" " & vbNewLine & _
                   "return theFiles"
    
        MyFiles = MacScript(MyScript)
        On Error GoTo 0
    
        If MyFiles <> "" Then
            With Application
                .ScreenUpdating = False
                .EnableEvents = False
            End With
    
            MySplit = Split(MyFiles, ",")
            For N = LBound(MySplit) To UBound(MySplit)
    
                ' Get the file name only and test to see if it is open.
                Fname = Right(MySplit(N), Len(MySplit(N)) - InStrRev(MySplit(N), Application.PathSeparator, , 1))
                If bIsBookOpen(Fname) = False Then
    
                    Set mybook = Nothing
                    On Error Resume Next
                    Set mybook = Workbooks.Open(MySplit(N))
                    On Error GoTo 0
    
                    If Not mybook Is Nothing Then
                        MsgBox "You open this file : " & MySplit(N) & vbNewLine & _
                               "And after you press OK it will be closed" & vbNewLine & _
                               "without saving, replace this line with your own code."
                        mybook.Close SaveChanges:=False
                    End If
                Else
                    MsgBox "We skipped this file : " & MySplit(N) & " because it Is already open."
                End If
            Next N
            With Application
                .ScreenUpdating = True
                .EnableEvents = True
            End With
        End If
    End Sub
    
    Function bIsBookOpen(ByRef szBookName As String) As Boolean
    ' Contributed by Rob Bovey
        On Error Resume Next
        bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
    End Function

  3. #3
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Inserting a Picture into Shape Quickly

    Can you Insert Shape (not smart art), including drawing the shape that you want and then right click the shape, choose to fill with a picture?
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  4. #4
    Registered User
    Join Date
    06-20-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac 2011
    Posts
    11

    Re: Inserting a Picture into Shape Quickly

    Yes, I can do this, but for the reporting I am doing I need to drop many pictures into the shapes and it takes too long right clicking and going through the folders, I'd like to be able to drop pictures in or have it open to a specific folder.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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