Advertisement
ItsPingu

Untitled

May 15th, 2025
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'module 1:
  2.  
  3. Public Function Notepad(sFile As String) As String
  4.     'Debug.Print "File: " & sFile
  5.    Notepad = "file.txt"
  6. End Function
  7.  
  8. 'module 2:
  9.  
  10. Sub ViewModel_Click()
  11.     Dim sLdCad As String, sFile
  12.     sFile = ActiveCell.Value
  13.     If Right(sFile, 4) = ".dat" Then
  14.       sLdCad = ActiveSheet.Range("B1").Value
  15.       'MsgBox (sLdCad & "\" & sFile)
  16.      Shell ("cmd /c " & sLdCad & "\" & sFile)
  17.     Else
  18.         MsgBox ("Must click on a .dat cell before clicking on this button")
  19.     End If
  20. End Sub
  21. Sub EditModel_Click()
  22.     Dim sLdCad As String, sFile
  23.     sFile = ActiveCell.Value
  24.     If Right(sFile, 4) = ".dat" Then
  25.         sLdCad = ActiveSheet.Range("B1").Value
  26.         Shell ("cmd /c start notepad """ & sLdCad & "\" & sFile & """")
  27.     Else
  28.         MsgBox ("Must click on a .dat cell before clicking on this button")
  29.     End If
  30. End Sub
  31.  
  32. 'module 3:
  33.  
  34. Sub InsertImagesFromURLs()
  35.     Dim cell As Range
  36.     Dim img As Picture
  37.     Dim imgURL As String
  38.     Dim targetCell As Range
  39.  
  40.     ' Loop through each cell in column B with a URL
  41.    For Each cell In Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).Row)
  42.         imgURL = cell.Value
  43.         If imgURL <> "" Then
  44.             ' Insert the image
  45.            Set img = ActiveSheet.Pictures.Insert(imgURL)
  46.            
  47.             ' Set the target cell for the image placement (same as the cell in column B)
  48.            Set targetCell = cell
  49.            
  50.             ' Position and size the image within the cell
  51.            With img
  52.                 .ShapeRange.LockAspectRatio = msoFalse
  53.                 .Left = targetCell.Left
  54.                 .Top = targetCell.Top
  55.                 .Width = targetCell.Width
  56.                 .Height = targetCell.Height
  57.             End With
  58.         End If
  59.     Next cell
  60. End Sub
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement