打开文件对话框

TypeName Function

Returns a string that provides Variant subtype information about a variable.

TypeName(varname)

The required varname argument can be any variable.

Return Values

The TypeName function has the following return values:

ValueDescription
ByteByte value
IntegerInteger value
LongLong integer value
SingleSingle-precision floating-point value
DoubleDouble-precision floating-point value
CurrencyCurrency value
DecimalDecimal value
DateDate or time value
StringCharacter string value
BooleanBoolean value; True or False
EmptyUnitialized
NullNo valid data
<object type>Actual type name of an object
ObjectGeneric object
UnknownUnknown object type
NothingObject variable that doesn't yet refer to an object instance
ErrorError
Remarks

The following example uses the TypeName function to return information about a variable:

Dim ArrayVar(4), MyType
NullVar = Null   ' Assign Null value.

MyType = TypeName("VBScript")   ' Returns "String".
MyType = TypeName(4)            ' Returns "Integer".
MyType = TypeName(37.50)        ' Returns "Double".
MyType = TypeName(NullVar)      ' Returns "Null".
MyType = TypeName(ArrayVar)     ' Returns "Variant()".
 
 

GetOpenFileName

This function creates a system-defined dialog box that enables the user to select a file to open.

BOOL GetOpenFileName( 
LPOPENFILENAME lpofn);
Parameters
lpofn
[in] Long pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetOpenFileName returns, this structure contains information about the user’s file selection.
Return Values

Nonzero indicates that the user specified a file name and clicked the OK button. The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains the full path and filename specified by the user.

Zero indicates that the user canceled or closed the Open dialog box or that an error occurred. To get extended error information, call GetLastError. GetOpenFileName sets only the ERROR_INVALID_PARAMETER and ERROR_OUTOFMEMORY errors.

Remarks

Not all members of the OPENFILENAME structure are defined in Windows CE. For information about the defined members, see the reference topic for the OPENFILENAME structure.

On a Palm-size PC, Windows CE modifies the meaning of the following members of the OPENFILENAME structure when it is passed into the GetOpenFileName function.

Flags
If this member is set to the OFN_PROJECT value, the GetOpenFileName function opens the Folder dialog box. Otherwise, the function opens the Open dialog box.
lpstrFile
When GetOpenFileName returns successfully, this member is used to retrieve full path of the selected file name.
lpstrFileTitle
When GetOpenFileName returns successfully, this member is used to retrieve the the project folder name only.
lpstrInitialDir
Pointer to a string that receives the initial folder name, but not the full path name.

When the GetOpenFileName function is called on a Palm-size PC, Windows CE adds the following prespecified undefined members:

  • lpstrCustomFilter
  • lpstrMaxCusFilter
  • lpstrDefExtension
  • lCustData
  • lpfnHook
  • lpstrTemplateName

eg:
Private Sub OpenExcel_Click()
FileToOpen = Application.GetOpenFilename("Microsoft Excel File(*.xls),*xls", , , True)
'FileToOpen = Application.GetOpenFilename("TEXT(*.txt),*txt", , , True)
TypeStr = UCase(TypeName(FileToOpen))
If TypeStr <> "BOOLEAN" Then
    Workbooks.Open Filename:=FileToOpen
Else
    Response = MsgBox("Import Cancel!", vbInformation, "Import Form")
    Exit Sub
End If
End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值