目錄檔 有二個欄位,分別為品號;品名
資料夾A, 裡面放圖檔(JPG檔),檔名為品號,目前作法是在目錄檔一筆一筆以插入_超連結設定連結對應該品號之圖檔,想請問如何能快速設定目錄中所有品號連結該對應的圖檔(筆數約有3000筆)
没有巨集或VBA使用經驗?
回答 (1)
Sub test()
Application.ScreenUpdating = False
DirPath = ThisWorkbook.Path & "\A"
fs = Dir(DirPath & "\*.jpg")
Do Until fs = ""
r = r + 1
fs = Replace(fs, ".jpg", "")
adds = "A\" & fs & ".jpg"
Range("A" & r + 1).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=adds, _
TextToDisplay:=fs
fs = Dir
Loop
Application.ScreenUpdating = True
MsgBox "完畢"
End Sub
收錄日期: 2021-05-04 02:03:16
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20151212184657AAMNiS6
檢視 Wayback Machine 備份