两种方法:
一、原代码不变,在工具箱按右键-“附加控件”,选择相应的控件即可。
二、不添加控件,直接修改代码:
Private Sub CommandButton3_Click()
Dim oDLG
Set oDLG = CreateObject("MSComDlgCommonDialog")
With oDLG
DialogTitle = "打开文件"
Filter = "文件|jpg;bmp"
FilterIndex = 1
MaxFileSize = 255
ShowOpen
If Filename <> "" Then
MeImage1Picture = LoadPicture(Filename)
End If
End With
Set oDLG = Nothing
End Sub
Private Sub Combo1_Change()
Call changetext
End Sub
Private Sub Combo1_Click()
Call changetext
End Sub
Private Sub changetext()
Dim cnn As New ADODBConnection
Dim rs As New ADODBRecordset
cnnOpen "provider=microsoftjetoledb40;extended properties=excel 80;data source=" & AppPath & "\天气及措施xls"
sql = "Select 措施 FROM [sheet1$] where 天气='" & Combo1Text & "'"
rsOpen sql, cnn
If Not rsEOF Or rsBOF Then
Text1Text = rsFields(0)Value
End If
rsClose
cnnClose
Set rs = Nothing
Set cnn = Nothing
End Sub
Private Sub Form_Load()
Dim cnn As New ADODBConnection
Dim rs As New ADODBRecordset
cnnOpen "provider=microsoftjetoledb40;extended properties=excel 80;data source=" & AppPath & "\天气及措施xls"
sql = "Select 天气 FROM [sheet1$]"
rsOpen sql, cnn
Do While Not rsEOF Or rsBOF
Combo1AddItem rsFields(0)Value
rsMoveNext
Loop
rsClose
cnnClose
Set rs = Nothing
Set cnn = Nothing
Combo1Text = Combo1List(0)
End Sub
如下代码可插入到指定单元格。
Range("a1")Select '选中A1单元格
ActiveSheetShapesAddShape(msoShapeRectangle, Range("a1")Left, _
Range("a1")Top, Range("a1")Width, Range("a1")Height)Select
SelectionShapeRangeFillUserPicture picpath '在A1单元格插入,大小与单元格一样。
VBA是Visual Basic for
Applications的缩写,是内嵌于office软件中的一个开发模块,这个模块提供程序自主开发,语言基础和VB(Visual
Basic)相似。在Excel的“工具—宏—编辑器”可以打开,也可按Alt+F11打开
以上就是关于怎么用vb在excel中上传图片 Dialog控件 commdlg.dll 高分悬赏~全部的内容,包括:怎么用vb在excel中上传图片 Dialog控件 commdlg.dll 高分悬赏~、VB中如何调用EXCEL中的一行数据本人想做一个VB调用EXCEL软件中的数据、VBA如何实现对excel中的图片网址自动插入图片等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)