In Excel, i have a Userform.
On this Userform is a Command Button, and a Label.
When i click the Command Button, i want excel to perform a web query, and then put the output into the caption of the label.
The web query is simply a .txt document on a webserver, containing one line of text, and i am trying to get excel to print this into the caption of the label.
So far, the code i have running when i click the Command Button is as follows:
And this successfully puts the line of text contained in the txt file into cell A1, however i can't figure out how to tell it to put that text into the label, which is called "Label1", instead of the cell.
My VBA ability is very limited, so keep that in mind...
Hoping someone can help...
On this Userform is a Command Button, and a Label.
When i click the Command Button, i want excel to perform a web query, and then put the output into the caption of the label.
The web query is simply a .txt document on a webserver, containing one line of text, and i am trying to get excel to print this into the caption of the label.
So far, the code i have running when i click the Command Button is as follows:
Code:
Private Sub CommandButton1_Click()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://www.exampleurl.com/textfile.txt", Destination:= _
Range("A1"))
.PostText = "local"
.Name = False
.FieldNames = False
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.HasAutoFormat = True
.RefreshOnFileOpen = 1
.BackgroundQuery = False
.TablesOnlyFromHTML = True
.SaveData = True
.Refresh BackgroundQuery:=False
End With
End Sub
And this successfully puts the line of text contained in the txt file into cell A1, however i can't figure out how to tell it to put that text into the label, which is called "Label1", instead of the cell.
My VBA ability is very limited, so keep that in mind...
Hoping someone can help...