Private Sub CommandButton2_Click()'开启网页
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE www.runoob.com/python/python-intro.html", vbNormalFocus
End Sub
Private Sub CommandButton2_Click()'调用外部程序
Shell "D:\Anaconda\python.exe D:\我的python\语音.py", vbNormalFocus
End Sub
Private Sub CommandButton3_Click()'调用Python发送邮件
Shell "python D:\我的python\新.py", vbNormalFocus
End Sub
Private Sub CommandButton3_Click()'开启程序微信
Shell "C:\Program Files (x86)\Tencent\WeChat\WeChat.exe", vbNormalFocus
End Sub
With CreateObject("internetexplorer.application")
.Visible = True
.Navigate "https://www.baidu.com/s?wd=扯乎"
'关闭网页
' .Quit
End With
EXCEL表格函数打开应用程序
如果是在工作表里,我们可以使用该函数:
=HYPERLINK("C:\Windows\System32\calc.exe","打开计算器")
Dim Program As String
Dim TaskId As Double
Program = "calc.exe" ' 计算器
On Error Resume Next '遇到错误,继续执行下面语句
AppActivate "计算器" ' 这里是应用程序面板的标题titile
If Err <> 0 Then ' 如果没有捕捉到‘计算器’程序,则err不等于0
Err = 0
TaskId = shell(Program, 1) ' 打开计算器
If Err <> 0 Then MsgBox "无法打开计算器"
End If
Private Sub CommandButton9_Click()'开启文件夹
Shell "explorer.exe D:\我的python", vbNormalFocus
End Sub
Private Sub CommandButton11_Click()
Workbooks.Open Filename:="C:\Users\Administrator\Desktop\证件登记.xlsm"
End Sub
import cv2#摄像头拍照片
cap = cv2.VideoCapture(0)
# 获得图片
ret, frame = cap.read()
# 展示图片
#cv2.imshow("captur", frame)
cv2.imwrite("captura.jpg", frame)
cap.release()
cv2.destroyAllWindows()
import cv2#人脸识别
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
xmlfile = r'D:\Anaconda\Lib\site-packages\cv2\data\haarcascade_frontalface_default.xml'
face_cascade = cv2.CascadeClassifier(xmlfile)
faces = face_cascade.detectMultiScale(
gray,
scaleFactor=1.15,
minNeighbors=5,
minSize=(5, 5),
)
print("发现{0}个目标!".format(len(faces)))
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x + w, y + w), (0, 255, 0), 2)
cv2.imshow("frame", frame)
# Display the resulting frame
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
Sub 宏4()
'
' 宏4 宏
'
'
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://m.sz.pegatroncorp.com/ASSA/Modules/Login/Login.aspx", Destination:= _
Range("$A$1"))
.Name = "www.so.com"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 1
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
import tkinter#时钟
import time
def gettime():
timestr = time.strftime("%H:%M:%S") # 获取当前时间并转换为字符串
lb.configure(text = timestr) # 重新设置标签文本
root.after(1000, gettime) # 每隔1S调用函数 gettime 自身获取时间
root = tkinter.Tk()
root.title('时钟')
lb = tkinter.Label(root, text = '', fg = 'blue', font = ("黑体", 80))
lb.pack()
gettime()
root.mainloop()