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

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

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

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

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

WebBrowserControl ... ActiveX



کد زیر دیالوگ باکسی برای گرفتن یک فایل باز می کند


Private Sub lblBrowse_Click()

'declare file dialog with late binding ->
Dim fDialog As Object, strPath As String
Set fDialog = Application.FileDialog(3) 'msoFilePicker

'set parameters ->
Me.wbContent.ControlSource = ""

    'initializing the file dialog ->
    With fDialog
        .AllowMultiSelect = False
        .Filters.Clear        '
        .title = "Please select a file..."

        'display the dialog box. If the .Show method returns True
        'the user picked a file. If the .Show method returns False
        'the user clicked Cancel.
        If .show = True Then
            strPath = .SelectedItems(1)
            Debug.Print "SELECTED_FILE: " & strPath

            'set source property to the string containing the full path ->
            Me.wbContent.ControlSource = strPath
            Me.wbContent.Requery
        Else

        End If
    End With


البته جواب نمیدهد خودتان را خسته نکنید ممکن است برای بعضی در WebBrowser نمایش داده شود.


Me.wbContent.ControlSource = "='" & strPath & "'"



WebBrowserControl.ControlSource Property : 

روی چک باکس یا Toggle Button عمل نمیکند ( ControlSource )


استفاده از پراپرتی ControlSource برای نمایش داده در کنترل

نمایش و  ویرایش داده متصل به یک جدول کوئری یا عبارت Sql یا نمایش نتیجه یک عبارت .( فرضا حاصلضرب دو تکست باکس یا فیلد از جدول یاکوئری)


You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.



Navigate2 Method  --->> internet-explorer

NavigateComplete2 event --->>  internet-explorer



expression.DocumentComplete (pDisp, URL)


pDisp  ( Required,Object)
A pointer to the IDispatch interface of the window or frame in which the document is loaded.
URL (Required,Variant)
Contains the URL of the loaded document.
Return value : Nothing


ByVal pDisp As Object

ByVal Url As Variant


Private Sub object_DocumentComplete( _
  ByVal pDisp As Object, _
  ByVal URL As Variant)


Document/getElementById





Set wb = WebBrowser0.Object 
wb.Silent = True
With wb
    .Navigate2 "about:blank"
    Do Until .ReadyState = 4 '=READYSTATE_COMPLETE
        'This is a somewhat inefficient way to wait, but loading a blank page should only take a couple of milliseconds
        DoEvents
    Loop
    .Document.Open
    .Document.Write "<!DOCTYPE html><HTML><HEAD><TITLE>My title</TITLE></HEAD><BODY scroll=""auto"" style=""margin: 0px; padding: 0px;"">" & _
                        "<embed src=""" & fileLocation & """  width=""100%"" height=""100%"" />" & _
                        "</BODY></HTML>"
    .Document.Close
End With





With Me.WebBrowser0.Object.Document.Open
.Write "<html><head></head><body><p>Some content.</p></body></html>"
.Close
End With

Opening A Blank Page
Me.WebBrowser0.ControlSource = "about:blank"

Me.WebBrowser0.Object.Document.parentWindow.execScript ("alert('Your Access Database " & Application.CurrentProject.Name & " rocks!');")

Me.WebBrowser0.Object.Document.body...


<!DOCTYPE html> <!-- saved from url=(0016)http://localhost --> <html> <head>



بخوانید و لذت ببرید 

جمع آوری از سایت های مختلف



OnLoad :
WebBrowser1.Navigate ("http://www.vbcity.com/forums/active.asp";) 'Replace with URL


Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    
 Next


Public WithEvents hDoc As MSHTML.HTMLDocument
Hdoc_ContextMenu=False




htmldocument



htmlcollection_loop


می توانید طبق لینک بالا لوپ را باکدهای HtmlDocument انجام بدهید ؟ در نظرات کد و نتیجه آن را مرقوم بفرمائید.


document


Dim HTML As HTMLDocument
Set HTML = WebBrowser1.Document HTML.All.Item("UNTextbox").Value = "UserName"
HTML.All.Item("PWTextbox").Value = "Password"
HTML.All.Item("LoginButton").Click


ورود داده به باکس UserName : 


Me.WebBrowser1.Navigate="Url" ' if be true

Me.WebBrowser1.Document.All("UserName").Value = "tester"



For Each ele In WebBrowser1.document.getelementsbytagname("a")

 If ele.innertext = "Log Out" Then

 ele.onclick = ""
 ele.click
 Exit For
  End If
Next



Private WithEvents m_body As MSHTML.HTMLBody

MsgBox "You clicked the page's body", vbInformation
Private Function m_body_onclick() As Boolean
End Function

Web Browsing Objects htm

browser-object-model

WebBrowser.GoForward Method webbrowser

WebBrowser.GoBack Method  webbrowser



Me.WebBrowser1.Document.Window.ScrollTo(0, 300)


WebBrowser1.Document.body.Scroll = "no"



CommandStateChange : برای فعال یا غیرفعال کردن دکمه های Forward و Back در مرورگر استفاده می شود . شکل کلی فراخوانی این event بصورت زیر است :

Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)


که command فرمانی است که حالت فعال آن تغییر کرده است و دو مقدار می گیرد : 1 و 3 که بترتیب معادل فرمانهای GoForward و GoBack هستند .
Enable فعال یا غیرفعال بودن فرمان را تعیین می کند .
2 – DocumentComplete : این event زمانی فعال می شود که صفحه در حال load شدن به حالت ReadyState_Complete برود . شکل کلی فراخوانی این event بصورت زیر است :

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
که pDisp ارجاعی به کنترل webbrowser است که event در آن رخ داده است و URL آدرس صفحه در حال load شدن است .
3 – DownloadBegin : این event در آغاز حرکت به صفحه جدید روی می دهد و هیچ پارامتری نمی گیرد . مرورگر می تواند در این event پیغامی برای شروع عملیات جدید نشان می دهد .
4 – DownloadComplete : این event در پایان عملیات یا در صورت انصراف کاربر یا بروز خطا روی می دهد .
5 – ProgressChange : با بروز هر تغییری در وضعیت load ، این event روی می دهد . شکل کلی فراخوانی آن بصورت زیر است :

Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)


که Progress نشان دهنده پیشرفت عملیات ( بایتهای load شده ) است . پارامتر ProgressMax تعداد کل بایتهایی که باید load شوند را نشان می دهد بنابر این :

(Progress/ProgressMax)*100=درصد پیشرفت عملیات load



Re: Disable webbrowser



Private Sub WebBrowser1_BeforeNavigate2(ByVa pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)

If Me.Visible Then Cancel = True

End Sub


If you don't want cursor or clicking then place the control in a frame and then disable the frame. Also format the border to none and clear caption.
You will need to comment out the code you currently have that moves the webbrowser control.