کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی
کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی

ShellExecuteA


عملی را روی فایل خاصی انجام میدهد.


مثل Edit ، Open یا Explore ، Print  و جنس آن از نوع String است.


طبق روش زیر برای ویندوز ۶۴ بیت قبل از فانکشن PtrSafe قرار گرفته بغیر از hWnd که نمایانگر پنجره است و nShowCmd که نمایانگر نمایش پنجره در وضعیت هایی است و از نوع عددی ( Long ) هستند بقیه پارامترها از نوع String می باشند.


#If VBA7 Then
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#Else
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#End If



lpFile specifies a document file, lpParameters should be NULL.


اگر lpFile سندی را مشخص کند lpParameters نمی تواند Null باشد.


The flags that specify how an application is to be displayed when it is opened. If lpFile specifies a document file,


nShow مشخص میکند چگونه یک اپلیکیشن زمانیکه باز میشود نمایش داده شود اگر lpFile یک فایلی مثل Word را مشخص نماید.


If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. 


اگر تابع درست انجام شود یک مقداری بزرگتر از ۳۲ را برمی گرداند می توانید با Msgbox در اکسس ببینید و اگر Fail دهد یا درست انجام نشود مقداری که علت انجام نشدنش باشد را نشان می دهد فرضا اگر دسترسی به فایل نداشته باشیم.


Example:
FileName = "C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Office\Microsoft Office Word 2003.lnk"

iRet = ShellExecute(GetDesktopWindow, "open", FileName, vbNullString, vbNullString, vbNormalFocus)
If lRet = 5 Then
    MsgBox "Access Denied" & vbCrLf & "Try pointing directely to the program EXE", , ""
End If



مثال بالا که از سایت گرفته شده نمایانگر این است که اگر دسترسی به فایلی امکانپذیر نبود بعلت محدودیت از طرف ادمین جعبه پیامی را باز کرده و به شما اعلام می نماید. ( GetDeskTopWindow یک هندل است که می بایست تابع آنرا در Module اضافه کنید در اینترنت تابع مورد نظر موجود است حتما از CloseHandle استفاده کنید.


ConstantValueDescription
vbHide0Window is hidden and focus is passed to the hidden window.
vbNormalFocus1Window has focus and is restored to its original size and position.
vbMinimizedFocus2Window is displayed as an icon with focus.
vbMaximizedFocus3Window is maximized with focus.
vbNormalNoFocus4Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus6Window is displayed as an icon. The currently active window remains active.










نظرات 0 + ارسال نظر
برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد