I am trying to pull elevation data from a website
http://www.gpsvisualizer.com/convert_input
I have successfully figured out how to programmatically click the 'Choose File' Button that brings up an Open File Dialog Box.
Private Sub browser_DocumentCompleted() Handles browser.DocumentCompleted
hDoc = browser.Document
Dim hInp As HtmlElement = hDoc.GetElementById("uploaded_file_1")
If hInp IsNot Nothing Then
hInp.Focus()
hInp.InvokeMember("Click")
End If
End Sub
Now I am stuck as to how to interact with the pop-up box. I need to fill in the file name of the file that I need to convert and click open from this Dialog box. Does anyone know how to do this?
Thanks!
Currently I am adding the path to the files that I want to upload to a listbox then copying each one to the clipboard and using sendkeys. I am not to thrilled with this method but it works.
Related
I want to open a PowerPoint Presentation that has a write password, directly with VBA without showing the dialog box, which asks to enter the password or open as Read-Only.
I can do this in a Word document with the following code:
Sub openWriteProtectedWord()
Documents.Open FileName:="C:\Users\user\Desktop\Doc2.docx", ReadOnly:=True
End Sub
When this is executed the file opens automatically without showing the pop-up where I have to click Read-Only button.
The code for PowerPoint:
Sub openWriteProtected()
Presentations.Open FileName:="C:\Users\user\Desktop\test.pptx", ReadOnly:=msoTrue
End Sub
When the code is executed the pop-up dialog shows up to enter password or open as read-only.
Is this a missing feature for PowerPoint, or it is done in another way?
I am currently trying to create a text editor in visual basic windows forms. I am using a toolstrip with file(new, open, save, save as, exit), edit(copy, cut, paste), and help(about)
I am trying to get the toolstrip to actually do all those things,
What I am trying to do is get those things to work with NORMAL textboxes and not rich textboxes.
I've got no problem getting these things to work with rich textboxes.
Dim dialog as NewOpenFileDialog
Dim file as string
dialog.ShowDialog()
file = Dialog.FileName
Dim sr as New StreamReadere(file)
Dim RichTextbox.Text = sr.ReadToEnd
sr.close()
The above code is for the open one that is what I use to click the file >> open but it only accepts rtf files.
So my question is how do I do the open files with normal textboxes so I can open ANY files.
I was just creating a template on Word which uses content controls and I have a userform to help auto fill the data which is activated via a command key. You know how on excel VBA you can click a cell to make it refresh or open up a userform, or perform a series of tasks. On Word, can you double or single click a Content Control per say and have a userform pop up?
I think it would be pretty neat to be able to do that, open for any ideas that I should try out.
Unlike Content Controls, ActiveX controls have Click and DoubleClick events. You can add an ActiveX control (e.g., a button or a label) and use its Click event to do whatever you want:
And then simply, use something like this:
Private Sub lblTest_Click()
MsgBox "You clicked on a label."
End Sub
Private Sub btnTest_Click()
MsgBox "You clicked on a button."
End Sub
Result:
Hope that helps.
I have a web browser control in a custom task pane control (User Control) and I open it as a sidebar as soon as my Outlook opens (I have created it as an Outlook Addin using Visual Studio 2013). The web browser control has a login form inside it and I would like to place focus on an input control in my web browser control as soon as Outlook opens. I have tried several tricks like placing focus on the custom user control and then placing focus on the input control after the form has loaded but it doesn't place focus on it. Also I have been trying to allow the use of Tab and Delete keys to work inside the web browser control so that I can tab to other controls and play with it like we would do it on a normal browser window. Kindly let me know how I can achieve this as I am out of ideas.
Cheers.
Try to use the Excel WebBrowser Control instead of the System.Windows.Forms WebBrowser; it handles special key forwarding as TAB, DEL, CTRL+V, etc.
For that change the WebBrowser contructor from
new System.Windows.Forms.WebBrowser();
to
new Microsoft.Office.Tools.Excel.Controls.WebBrowser();
You would need to add references to your project:
Project/Add Referernce/Extensions select
Microsoft.Tools.Outlook & Microsoft.Tools.Outlook.v4.0.Utilities
Doc: https://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.controls.webbrowser.aspx
You can only do that if you install a Windows hook (SetWindowsHookExW(WH_GETMESSAGE, YourHookProc, 0, GetCurrentThreadId()) and in the hook proc detect that messages are supposed to go to your browser, and redirect them accordingly.
It works partially this way but not 100%. First I had to set the TabStop property to True for my webbrowser control and then just set the focus once the document was loaded and that was it. The tab, delete, backspace keys all ran properly.
Private Sub CustomTaskPane_Load(sender As Object, e As EventArgs) Handles Me.Load
TestWebBrowser.Size = New Drawing.Size(Me.Width, Me.Height)
Me.Focus()
TestWebBrowser.Navigate(url)
WaitForPageLoad()
TestWebBrowser.TabIndex = 0
TestWebBrowser.TabStop = True
End Sub
Private Sub TestWebBrowser_DocumentCompleted(sender As Object, e As Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles TestWebBrowser.DocumentCompleted
' Now set the focus on the Web Browser Control
TestWebBrowser.Focus()
End Sub
I have written a form based document generation macro (in VBA) for distribution to a sales team.
For their ease of use, I want to provide a self-contained file which will display the form as soon as the document is opened.
Using AutoOpen I can get the form to display as intended if word is already open and the dotm file is opened within. However, if I double click the file from within explorer, nothing happens and I have to launch the macro manually. I thought AutoExec might allow this but no luck there. I've spent considerable time trying to get this to work through googling etc. but I'm not getting anywhere.
How can I make the form display even when the file is opened with a double click? Is it possible to do this without having to change normal.dotm for each user?
For further background, I am using Word 2013 with macros fully enabled during testing. The dotm file is stored in a trusted location.
I am using a macro to launch the form like this...
Public Sub AutoOpen()
StartPage.Show
End Sub
I have tried using AutoExec as well to no avail.
In the "generator.dotm" file got to Visual Basic and go in to the "ThisDocument" Microsoft Word Object.
At the top of the Visual Basic Editor select "Document" in the left hand side and then click on "New" on the right hand side. Private Sub Document_New() method will appear for you to be able to edit. Then you can call your userform in there. Similar to:
Private Sub Document_New()
Dim myForm As UserForm1
Set myForm = New UserForm1
myForm.Show
End Sub
Save your Generator.dotm and double click it through Windows explorer and you should get the results that you would like.