当前位置:首页教育技巧excel技巧excel表格制作

vba如何用excel检索

2025-12-26 09:34:07


1.如何用VBA在Excel中查找指定文件中PDF图片并打开它

Sub openpdf()

Dim path$

Dim name$

Dim fullname$

name = InputBox("请输入文件名称(不含扩展名)")

path = "G:\360data\重要数据\桌面\"

fullname = path & name & ".pdf"

CreateObject("Wscript.Shell").Run (fullname)

End Sub

2.excelvba问题怎么使我查询后的名称不会变成日期型,我要的是

With Worksheets("查询") 。

Cells(b, 1)。NumberFormat = "m月d日" '格式化日期 。

Cells(b, 1)。Value = riqi 。

Cells(b, 2)。NumberFormat = "@" '格式化文本 。

Cells(b, 2)。Value = danhao 。

Cells(b, 3)。Value = mingchen 。

Cells(b, 4)。Value = danwei 。

Cells(b, 5)。Value = shuliang 。

Cells(b, 6)。Value = danjia 。

Cells(b, 7)。Value = jine 。

Cells(b, 8)。Value = kehu 。

Cells(b, 9)。Value = beizhu End With 其实这个查询的代码可以优化一下,用高级筛选的话,只要一句代码就好了。

3.怎么用VBA在EXCEL表格中检索对应的产品编号的产品图片,求指教

Private Sub Worksheet_Change(ByVal Target As Range)Dim Myname As StringDim Mypath As StringDim Picname() As StringOn Error Resume NextMypath = "C:\Users\Administrator\Pictures\图片\"If Target.Count = 1 And Target.Column = 1 ThenMyname = Dir(Mypath & Target.Value & "*.jpg", 0)i = 0For k = 0 To 10ActiveSheet.Shapes("B" & Target.Row & k).DeleteIf Err.Number = 440 ThenExit ForEnd IfNext kDo While Myname <> ""ReDim Preserve Picname(i)Picname(i) = Mynamei = i + 1Myname = DirLoopFor j = 0 To i - 1With ActiveSheet.Pictures.Insert(Mypath & Picname(j)).Top = Target.Offset(0, 1).Top.Left = Target.Offset(0, 1).Left + j * Target.Offset(0, 1).Width / (i).ShapeRange.LockAspectRatio = msoFalse.Height = Target.Offset(0, 1).Height.Width = Target.Offset(0, 1).Width / (i).Name = "B" & Target.Row & jEnd WithNext jEnd IfEnd Sub在你使用的表格的CHANGE事件,添加上面代码看看是不是符合要求。

4.如何利用Excel vba程序将每张工作表转成jpg格式的图片

'需安装有打印机"Microsoft Office Document Image Writer"Sub test() On Error Resume Next Dim i As Integer For i = 1 To Sheets.Count Sheets(i).PrintOut ActivePrinter:="Microsoft Office Document Image Writer", PrToFileName:=Sheets(i).Name & ".mdi" NextEnd Sub。

相关信息


电脑版

【免责声明】本站信息来自网友投稿及网络整理,内容仅供参考,如果有错误请反馈给我们及时更正,对文中内容的真实性和完整性本站不提供任何保证,不承但任何责任。
版权所有:学窍知识网 Copyright © 2011-2026 www.at317.com All Rights Reserved .