ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] §PÂ_¸ê®Æ§¨¤º¬O§_¦³ÀÉ®×

[µo°Ý] §PÂ_¸ê®Æ§¨¤º¬O§_¦³ÀÉ®×

¥»©«³Ì«á¥Ñ a703130 ©ó 2012-12-5 10:32 ½s¿è

¤U­±¬O§Úªº¤@³¡¥÷µ{¦¡½X,¥Ø¼Ð¬O±qa.xls§ìÀɮצWºÙ,¦A¥h¸ê®Æ§¨¤º§ì¨ú¹ÏÀÉ,­×§ï¤j¤p«á©ñ¦^a.xlsÀÉ
¥Ø«e¹J¨ì¤@­Ó°ÝÃD,´N¬O·í§Úa.xls§ì¤FÀɮצWºÙ,¦ý¬O¸ê®Æ§¨¤º¨S¦³ÀÉ®×,§Ú¸Ó¦p¦ó§PÂ_

¬O§_¦b²Ä15¦æ«e¥[¤J¤@§PÂ_¦¡,§PÂ_ÀɮצWºÙ¬O§_¦s¦b©ó¸ê®Æ§¨,¦pªG¨S¦³«hÂ÷¶}if §PÂ_¦¡
§PÂ_Àɮ׬O§_¦s¦b,³o³¡¤À§Ú¤£ª¾¹D¦p¦ó¼g~¬O§_¯à½Ð«e½úÀ°¦£,·P¿E¤£ºÉ
  1. Sub InsertImage(ImagePath, FolderName)
  2.     Dim ReadRow As Integer
  3.     Dim ImageName As String
  4.     Sheets("a").Select
  5.     ReadRow = 24
  6.    
  7. '§PÂ_Safety­¶­±²Ä¤@Äæ¬O§_¦³»Ý­n¸ü¤J¹ÏÀɪ½¦Ü¥X²{"END"¦r¼Ë
  8.     Do Until UCase(Cells(ReadRow, 1)) = "END"
  9.         ImageName = Cells(ReadRow, 1)
  10.         
  11. '§Q¥ÎCheckFileName func ¨Ó§PÂ_¬O§_¦³ÃöÁä¦r ".PNG & .JPG"¡A¦pªG¦³«h¸ü¤J¹Ï¤ù
  12.         If CheckFileName(UCase(ImageName)) = True Then
  13.             Cells(ReadRow, 2).Select
  14.             ActiveSheet.Pictures.Insert(ImagePath & "\" & FolderName & "\" & ImageName).Select
  15.             Call ImageSize
  16.         Else
  17.         End If
  18.         ReadRow = ReadRow + 1
  19.     Loop
  20. End Sub

  21. Function CheckFileName(ByVal ImageName As Variant) As Boolean
  22.     Dim ImageLenth As Integer
  23.     Select Case ImageName
  24. '¦pªGªÅ¥Õ«hÂ÷¶}¦¹ func
  25.     Case Is = ""
  26.         CheckFileName = False
  27.         Exit Function
  28. '­pºâ¦r¦êªø«×¨ÃÂ^¨ú«á­±4­Ó¦r¤¸¡A§PÂ_¬O§_¦³ÃöÁä¦r ".PNG & .JPG"¡A¦pªG¦³«h¸ü¤J¹Ï¤ù
  29.     Case Else
  30.         ImageLenth = Len(ImageName)
  31.         ImageName = Mid(ImageName, ImageLenth - 4 + 1, 4)
  32.         If ImageName = ".PNG" Or ImageName = ".JPG" Then
  33.             CheckFileName = True
  34.         Else
  35.             CheckFileName = False
  36.         End If
  37.     End Select
  38. End Function

  39. '³]©w¹ÏÀɪºSize¤j¤p¤Î¦ì¸m
  40. Sub ImageSize()
  41.     Selection.ShapeRange.LockAspectRatio = msoFalse
  42.     Selection.ShapeRange.Height = 289.5
  43.     Selection.ShapeRange.Width = 531.75
  44.     Selection.ShapeRange.Rotation = 0#
  45.     Selection.ShapeRange.IncrementLeft 5#
  46.     Selection.ShapeRange.IncrementTop 5#
  47. End Sub
½Æ»s¥N½X

¤w¸g¤£¯à½s¿è©«¤l~À³¸Ó¬O14¦æ¤W­±,´¡¹Ï¤ù¤§«e

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-12-5 11:17 ½s¿è

¦^´_ 1# a703130
  1. Option Explicit
  2. Sub Ex() '§PÂ_¸ê®Æ§¨¤º¬O§_¦³ÀÉ®×
  3.     'Dir("D:\test\*.PNG") = "" ¬°¸ê®Æ§¨¤¤ÀɮרS¦³°ÆÀɦW¬OPNGªºÀÉ®×
  4.     '§PÂ_¸ê®Æ§¨¤¤Àɮ׬O§_¦³ÃöÁä¦r ".PNG & .JPG"
  5.     If Dir("D:\test\*.PNG") = "" And Dir("D:\test\*.JPG") = "" Then MsgBox "¸ê®Æ§¨¤¤¨S¦³ .PNG  .JPG"
  6. End Sub
½Æ»s¥N½X
¾ã²z¤@¤U§Aªºµ{¦¡½X
  1. Option Explicit
  2. Sub InsertImage(ImagePath, FolderName)
  3.     Dim ReadRow As Integer, ImageName As String
  4.     Sheets("a").Select
  5.     ReadRow = 24
  6.     '§PÂ_Safety­¶­±²Ä¤@Äæ¬O§_¦³»Ý­n¸ü¤J¹ÏÀɪ½¦Ü¥X²{"END"¦r¼Ë
  7.     Do Until UCase(Cells(ReadRow, 1)) = "END"
  8.         'ImageName = Cells(ReadRow, 1)
  9.         ImageName = ImagePath & "\" & FolderName & "\" & Cells(ReadRow, 1)
  10.         If InStr(ImageName, ".PNG") Or InStr(ImageName, ".JPG") Then
  11.             If Dir(ImageName) <> "" Then
  12.                 Cells(ReadRow, 2).Select
  13.                 ActiveSheet.Pictures.Insert(ImageName).Select
  14.                 Call ImageSize
  15.             End If
  16.         End If
  17.         ReadRow = ReadRow + 1
  18.     Loop
  19. End Sub
½Æ»s¥N½X

TOP

ÁÂÁ«e½ú,ÁٳҷбzÀ°§Ú¾ã²zµ{¦¡½X,¦]¬°ÁÙ¤£¼ô±x©Ò¥H¨ì³B³£¬Oµù¸Ñ

Ãö©óDIR ¦³¶i¤@¨B»{ÃѤF

TOP

        ÀR«ä¦Û¦b : ¡i¥Í©R¦b©I§l¶¡¡j¦òªû»¡¡G¡u¥Í©R¦b©I§l¶¡¡C¡v¤HµLªkºÞ¦í¦Û¤vªº¥Í©R¡A§óµLªk¾×¦í¦º´Á¡AÅý¦Û¤v¥Ã¦í¤H¶¡¡C¬JµM¥Í©R¥h¨Ó³o»òµL±`¡A§Ú­Ì§óÀ³¸Ó¦n¦n¦a·R±¤¥¦¡B§Q¥Î¥¦¡B¥R¹ê¥¦¡AÅý³oµL±`¡BÄ_¶Qªº¥Í©R¡A´²µo¥¦¯uµ½¬üªº¥ú½÷¡A¬M·Ó¥X¥Í©R¯u¥¿ªº»ù­È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD