How to navigate using WebBrowser Control? I want to open a C:\file1.html... an example code would be appreciated.
The VB code you have is correct, that is an error with the javascript on the page you are loading, so you can use:
Private Sub Command1_Click()
WebBrowser1.Navigate2 "C:\file1.html"
End Sub
But in Form_Load set silent mode, eg:
Private Sub Form_Load()
WebBrowser1.silent = true
End Sub
i first put a webcomponent as mentioned in the post "How do i open a webpage" in vb6 by adatapost
Private Sub Command1_Click()
WebBrowser1.Navigate2 "C:\file1.html"
End Sub
this works but as u click on the button it pops a error..A error has occured on the scirpt of the page , line 6, Error: object expected, url: file:///C:file1/index.html, do u want to continue , yes or NO............................how to come around this error. ??
Related
I am trying to automate some SAP Data reports, I am using VisuaL Basic 2017 and SAP Logon 750, all works fine so far but if there's an open connection then a pop up shows with message:
"User XXXXX is already logged" and 3 radio buttons
How can I choose radio button and click either on Confirm Button or Cancel button?
I want to click on the check or button and continue with the same logon.
How can I accomplish that?
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Get_Btn.Click
'=============================
Dim application As Object
Dim SapGui As Object
Dim connection As Object
Dim session As Object
'=================Check Open Sessions==================
'===Activate SAP logon pad engine
application = CreateObject("Sapgui.ScriptingCtrl.1")
'===Initiate one of the predefined SAPlogon pad connection
SapGui = GetObject("SAPGUI")
application = SapGui.GetScriptingEngine
connection = application.OpenConnection("LA TEST", True)
session = connection.children(0)
Try
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "zc98"
session.findById("wnd[0]").sendVKey(0)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
Thanks!!
You can activate the script recording before logging on to SAP. Then you can see which commands are used. In my test example I recognized the following:
...
session.findById("wnd[1]/usr/radMULTI_LOGON_OPT1").select
session.findById("wnd[1]/tbar[0]/btn[0]").press
...
Regards, ScriptMan
Ok, after searching for an hour, I still haven't found the right answer for this. All I want is to disable the right click on my button because it's creating a bug, according to our tester. I don't know if VB6 can't do this, but if VB6 can't do this, is there any possible way? Ok, just to be more specific, here is my example...
'I found this somewhere...
Private Sub cmdExportCSV_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
'Do Nothing
End If
End Sub
'Then I have here
Private Sub cmdExportCSV_Click()
'Some logic here
End Sub
But when I click the right button on my mouse, the cmdExportCSV_Click() still executing the code inside.
How about something like this then (based upon your code):
Private m_mouseButton As Integer
Private Sub cmdExportCSV_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
m_mouseButton = Button
End Sub
Private Sub cmdExportCSV_Click()
If m_mouseButton = vbRightButton Then
'Do Nothing
Exit Sub
End If
'Some logic here
End Sub
I didn't run this or anything, but it should work.
I have resolved my own problem.
From this..
Private Sub cmdExportCSV_Click()
If m_mouseButton = vbRightButton Then
'Do Nothing
Exit Sub
End If
'Some logic here
End Sub
To this..
Private Sub cmdExportCSV_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbRightButton Then
Exit Sub
End If
'Some logic here
End Sub
That's it! VB6 won't directly allow you to disable the mouse right and mouse left button. My solution is just to exit event whenever the user click the mouse right button.
Anyway, I'm sorry as I found out that the system is using asImageCommand not CommandButton, so when you declare an event like this "Private Sub cmdExportCSV_Click()", the asImageCommand control will trigger when you click the mouse-right and mouse-left button. But if you are using CommandButton, it will only trigger when you click the left-button, and won't allow you to use the right-button of the mouse.
I think I have to update the title of my question.
I'm in the process of converting some outlook VBA macros to an Add-in. I am having difficulty with my macros that create emails based on a template. I decided to code a simple button to create and display a new email with the subject test.
Everything is working up to displaying the email which doesn't happen.
Private Sub ButtonGenEmail_Click(sender As Object, e As EventArgs) Handles ButtonGenEmail.Click
Me.Close()
Dim objApp As Outlook.Application
Dim objMail As Outlook.MailItem
objApp = Globals.ThisAddIn.Application
objMail = objApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
objMail.Subject = "test"
objMail.Save()
objMail.Display(False)
End Sub
At one point I added msgbox "Done" after objMail.Display(False) and the message never appears.
Thanks in advance
This should obviously work. I'm not so skilled in Outlook but I guess the problem here is that you run it from a form (I see the Me.Close)
Isn't then Outlook blocking to display the mail because the form is still open (I guess modal = ShowDialog())?
I think you will have to either change the form to be not modal (use Show() instead of ShowDialog()) or handle the event after the form is closed, something like
All code below written from top of my mind, so I may miss something
A method from where you initialize the form
Dim frm as new YourForm()
frm.ShowDialog()
if frm.MyState = TheyClickOnButton Then
' Run your mailItem code here
End If
in the form code
Public Enum State
Unknown = 0
TheyClickedOnButton
End Enum
Public Property MyState as State
Private Sub ButtonGenEmail_Click(sender As Object, e As EventArgs) Handles ButtonGenEmail.Click
MyState = TheyClickedOnButton
Me.Close()
End Sub
I'm trying to page and sort my DataGrid which is inside a ModalPopupExtender but I can't page it in any way, already tried with <Triggers>, put the UpdatePanel inside, outside, in the middle, and it does NOT work. Modal popup does not get closed but the grid just disappears. Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
BindData()
End If
End Sub
Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
SqlServerDS.SelectCommand = "SELECT * FROM emp WHERE name LIKE '%" & txtSearchName.Text & "%'"
BindData()
End Sub
Private Sub BindData()
grdSearch.DataSource = SqlServerDS
grdSearch.DataBind()
End Sub
Private Sub grdBuscaPaciente_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdSearch.PageIndexChanging
grdSearch.PageIndex = e.NewPageIndex
BindData()
End Sub
Inside the Designer, this is the code h:
<modalpopupextender>
</modalpopupextender>
<panel>
<updatepanel>
<gridview>
</gridview>
</updatepanel>
</panel>
Tommy is right, so what you just have to do is re-show the popup.
After the BindData() in the PageIndexChanging event show the panel again with the Show() method of the popup extender.
This code is in c# but is pretty much the same.
gvHorarioPB.DataSource = (DataTable)Session["Prueba"];
gvHorarioPB.PageIndex = e.NewPageIndex;
gvHorarioPB.DataBind();
//mpePB is my modalpopupextender
this.mpePB.Show();
If you are using the .NET AJAX toolkit, keep in mind that each time you click someting (paging, sorting, etc.), the page performs a postback, even if it looks AJAX-y. Meaning that you will need to rebind the data each time. Try removing the IfPostback in your page load and see what that does for you.
I have an application written in VBA for Excel that takes in a live data feed. Whenever there is a change in the data, various events are triggered within VBA.
I also have some UserForms with ComboBoxes on them. My problem is that when I click the down arrow on the ComboBox and try to make a selection, the moment I get an update from the data feed, the ComboBox resets. What I would like to do is pause the events while I am making my selection in the ComboBox and then unpause it when I am done. How do I generate this functionality?
Try this to turn off:
application.enableevents = false
And this to turn back on:
application.enableevents = true
To pause and show a message and to keep working on something during the pause. finally press button
Public Ready As Boolean
Private Sub Command1_Click()
Ready = True
End Sub
Private Sub Form_Load()
Me.Show
Ready = False
Call Wait
Label1.Visible = True
End Sub
Public Function Wait()
Do While Ready = False
DoEvents
Loop
End Function
Maybe you can put a flag to bypass the update event on your combobox until a selection is made.
Private bLock as boolean ' declare at module level
' When a user clicks on the combobox
Private Sub DropDownArrow_Click() ' or cboComboBox_Click()
bLocked = True
End Sub
' This procedure is the one that does the updating from the data source.
' If the flag is set, do not touch the comboboxes.
Private Sub subUpdateComboBoxes()
If Not bLocked then
' Update the comboboxes
End If
End Sub
' When the selection is made, or the focus changes from the combobox.
' check if a selection is made and reset the flag.
Private Sub cboComboBox_AfterUpdate() ' Or LostFucus or something else
if Format(cboComboBox.Value) <> vbNullString Then
bLocked = False
End If
End Sub
Hope that helps.