Results 1 to 2 of 2

Replace text with image using VBA on Mac Excel 2017

Threaded View

  1. #1
    Registered User
    Join Date
    11-25-2021
    Location
    Singapore
    MS-Off Ver
    2021
    Posts
    4

    Replace text with image using VBA on Mac Excel 2017

    I tried to use this VBA code to replace text (name of the image) with images but somehow this code only works on windows excel.
    Always get N/A as the answer. Please kindly help

    Sub InsertPicture()
    Dim xPath As String
    Dim xLastRow As Long
    Dim Rng As Range
    Dim WorkRng As Range
    On Error Resume Next
    xTitleId = "MosaicExcel"
    Set WorkRng = Application.Selection
    Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
    Application.ScreenUpdating = False
    xPath = "Macintosh HD/Users/davidhuy/Downloads/400"
    If Right(xPath, 1) <> "\" Then xPath = xPath & "\"
    xLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    For Each Rng In WorkRng
        If Rng.Value <> "" Then
            If Dir(xPath & Rng.Value & ".jpg") <> "" Then
                ActiveSheet.Pictures.Insert(xPath & Rng.Value & ".jpg").Select
                With Selection.ShapeRange
                    .LockAspectRatio = msoFalse
                    .Left = Rng.Left
                    .Top = Rng.Top
                    .Width = Rng.Width
                    .Height = Rng.Height
                End With
                Rng.ClearContents
            Else
                Rng.Value = "N/A"
            End If
        End If
    Next
    Application.ScreenUpdating = True
    End Sub
    Last edited by davidhuy; 01-10-2022 at 02:31 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 01-07-2021, 11:57 AM
  2. Replies: 1
    Last Post: 01-07-2021, 11:26 AM
  3. Imported text 12/8/2017 becomes 8/12/2017
    By terrypin in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 02-20-2018, 02:46 PM
  4. Replies: 2
    Last Post: 10-01-2017, 02:38 PM
  5. [SOLVED] How to format dates like 9/25/2017 to 09/25/2017
    By chessmonsta in forum Excel General
    Replies: 11
    Last Post: 03-17-2017, 03:11 AM
  6. VBA: Put text from excel to jpeg image by matching image name.
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 01:47 AM
  7. Replace Text in Word Document with Image?
    By nickypatterson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-29-2011, 04:28 PM

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