惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
Engineering at Meta
Engineering at Meta
美团技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 司徒正美
I
InfoQ
S
SegmentFault 最新的问题
博客园 - 叶小钗
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
IT之家
IT之家
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
月光博客
月光博客
The Cloudflare Blog
U
Unit 42
GbyAI
GbyAI
L
LangChain Blog
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 隨風.NET

使用omdd下载ollama 钉钉AI机器人 安全高效跨平台的. NET 模板引擎 Fluid 使用文档 IIS反向代理 anki单词发音 excelPackage.Workbook.Worksheets[0]”引发了类型“System.Collections.Generic.KeyNotFoundException”的异常 vba替换\ red-gate激活要点 简化asp.netcore框架 python 调用dnspod接口修改A记录 windows安装nginx服务 jquery根据json自动生成表格 动态生成类并通过反射调用 搭建prometheus监控系统 .net core部署到k8s 异步异常无法catch 虚拟机安装k8s 优化 vue 使用 webpack 打包,出现的缓存问题 及 项目部署问题 Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException 拒绝访问 / 出现了内部错误 c# – 当使用X509Certificate2加载p12/pfx文件时出现
excel 链接变图片
隨風.NET · 2023-06-01 · via 博客园 - 隨風.NET


'Sub getpicture()
'Dim d, i&, sp As Shape, arr
'Set d = CreateObject("scripting.dictionary")
'For Each sp In Sheet1.Shapes
'   If sp.Type = msoPicture Then
'      Set d(sp.TopLeftCell.Offset(, -1).Value) = sp
'   End If
'Next
'arr = Sheets(2).Range([a2], [a65536].End(3))
'For i = 1 To UBound(arr)
'   If d.exists(arr(i, 1)) Then
'      d(arr(i, 1)).Copy
'      Cells(i + 1, 2).Select
'      ActiveSheet.Paste
'   End If
'Next
'ActiveWindow.ScrollRow = 1
'
'End Sub
' windows api
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

' sleep(毫秒)
Sub sleep(T As Long)
    Dim time1 As Long
    time1 = timeGetTime
    Do
        DoEvents
    Loop While timeGetTime - time1 < T
End Sub


Sub getpicture()
Dim d, i&, sp As Shape, arr, xb As Workbook

'设置图片库数组
Set xb = GetObject(ActiveWorkbook.Path & "\图片库.xlsx")
'Set xb = GetObject("C:\图片库.xlsx")
Set d = CreateObject("scripting.dictionary")
For Each sp In xb.Sheets(1).Shapes
   If sp.Type = msoPicture Then
      Set d(sp.TopLeftCell.Offset(, -1).Value) = sp
   End If
Next

'读取首行
Dim y As Double
y = Selection.Column() '列数

arr = ActiveSheet.Range(Cells(1, y - 1), Cells(65536, y - 1).End(3))
For i = 1 To UBound(arr)
   If d.exists(arr(i, 1)) Then
      sleep 100
      d(arr(i, 1)).Copy
      Cells(i, y).Select
      On Error Resume Next
      ActiveSheet.Paste
   End If
Next
ActiveWindow.ScrollRow = 1

End Sub


Sub getpictureurl()



Dim ranTotal As Range, rng As Range, imageRng As Range, x As Double '设定三个Range变量

x = Selection.Column()
'MsgBox x, vbOKOnly, "鼠标选区的地址"


'Set rngTotal = Range(Columns(x), Columns(x)) '选中存放网址的o列
Set rngTotal = Selection
For Each rng In rngTotal     '遍历所有的o列单元格
    If Left(rng.Value, 7) = "http://" Then '如果单元格内容为网址
        Set imageRng = rng.Offset(, 1)  '存放图片的地址
        With ActiveSheet.Pictures.Insert(rng.Value)
            .Top = rng.Top
            .Left = rng.Left + (rng.Width - .Width * rng.Height / .Height) / 2
            .Width = .Width * rng.Height / .Height
            .Height = rng.Height
            rng.Value = ""
        End With
    End If
Next

End Sub


Sub deletepicture()
Dim Tupian As Shape
        For Each Tupian In ActiveSheet.Shapes
            If Tupian.Name Like "Picture *" Then Tupian.Delete
        Next

End Sub

Sub 工具栏()
With Application.CommandBars.Add(, , , True)
With .Controls.Add
     .Caption = "匹配本地图片"
     .TooltipText = "匹配本地图片"
     .OnAction = "getpicture"
     .Style = msoButtonIconAndCaption
    End With
    .Visible = True
    
    With .Controls.Add
     .Caption = "清除图片"
     .TooltipText = "清除图片"
     .OnAction = "deletepicture"
     .Style = msoButtonIconAndCaption
    End With
    .Visible = True
 
    
With .Controls.Add
     .Caption = "匹配网络图片"
     .TooltipText = "匹配网络图片"
     .OnAction = "getpictureurl"
     .Style = msoButtonIconAndCaption
    End With
    .Visible = True
      End With
End Sub


Function GetColumnStr(n&) As String

  Dim i&

  If n > 26 Then

    If n Mod 26 = 0 Then i = n \ 26 - 1 Else i = n \ 26

    GetColumnStr = GetColumnStr(i) & GetColumnStr(n - (i) * 26)

  Else

    GetColumnStr = Chr(n + 64)

  End If
End Function