选项显式“”文件打开对话框“”作者未知公共声明函数GetOpenFileName Lib“comdlg32.dll”\uAlias“GetOpenFileNameA”(pOpenfilename作为OPENFILENAME)作为LongPublic类型OPENFILENAME lStructSize作为Long hwndOwner作为Long hInstance作为Long lpstrFilter作为字符串lpstrCustomFilter作为字符串NMaxustFilter作为Long nFilterIndex只要lpstrFile作为字符串nMaxFile只要lpstrFileTitle作为字符串nMaxFileTitle只要lpstrInitialDir作为字符串lpstrTitle作为字符串标志只要nFileOffset作为整数nFileExtension作为整数lpstrDefExt作为字符串lCustData只要lpfnHook作为长lpTemplateName作为StringEnd类型'@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~对话框“@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@公共函数ShowOpen()作为字符串Dim strTemp作为字符串Dim VertName作为OPENFILENAME VertName。lStructSize=Len(VertName)VertName。hwndOwner=此图纸。HWND VertName。lpstrFilter=“所有Excel文件(*.xls)”+Chr$(0)+_“*.xls”+Chr$(0)+“|”+“Excel文件(*.xlsx)”+Chr$(0)+_“*.xlsx”VertName。lpstrFile=空格$(254)VertName。nMaxFile=255顶点名称。lpstrFileTitle=Space$(254)VertName。nMaxFileTitle=255顶点名称。lpstrInitialDir=CurDir VertName。lpstrTitle=“选择Excel文件”VertName。标志=0如果GetOpenFileName(VertName),则strTemp=(Trim(VertName.lpstrFile))ShowOpen=Mid(strTemp,1,Len(strTemp)-1)End IfEnd FunctionPublic Sub DrawRectangleEx()Dim xlFileName As String On Error GoTo Err\u Control xlFileName=ShowOpen()Dim Excel As Object On Error Resume Next Set Excel=GetObject(,“Excel.Application”),如果出错,则出错。清除End If On Error GoTo 0 Set Excel=CreateObject(“Excel.Application”),如果出现错误,则MsgBox“无法加载Excel。”,VBEXPECTION End End If Dim xlBook As Object Dim xlSheet As Object Excel。Visible=True Set xlBook=Excel。工作簿。打开(xlFileName)设置xlSheet=xlBook。工作表(“表1”)