Thread: web box address
View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Atishoo Atishoo is offline
external usenet poster
 
Posts: 267
Default web box address

Have got the browsers present at the top of my board and working great! they
just display as windows, no address bar or anything, i control the address by
the active row and want to do the opposite (set the address to the active row
via a command button that will deliver the address that the user has
navigated to in the column "ar" in the active row) thereby the user can set
whos info the browser shows automatically, if that makes sense! Only trouble
is that no matter how I twist it i keep getting the workbooks address on the
C drive instead! Might be defeated by this one!

"Joel" wrote:

What is this statement doing?

BrowserPresent = BrowserPresent Or TypeName(anOLEObj.Object)
= "WebBrowser"

You can also open an Explorer object by simply doing this

anOLEObj.activate

"Atishoo" wrote:

Oh this problem is driving me nuts!
Maybe this might shed some light?
I used the folowing sub to create my browsers for me does this make a
difference to the way i should be retrieving the displayed web page?


Sub addbrowser()
'
' addbrowser Macro
'
'Application.CommandBars("Control Toolbox").Visible = True
Dim anOLEObj As OLEObject, BrowserPresent As Boolean
For Each anOLEObj In ActiveSheet.OLEObjects
BrowserPresent = BrowserPresent Or TypeName(anOLEObj.Object) =
"WebBrowser"
Next anOLEObj
If Not BrowserPresent Then
Set anOLEObj =
ActiveSheet.OLEObjects.Add(ClassType:="Shell.Explo rer.2", Link:=False, _
DisplayAsIcon:=False, Left:=461.25, Top:=293.25, Width:=190.5,
Height _
:=95.25)
anOLEObj.Object.Name = "WebBrowser1"
End If
ActiveSheet.Shapes("WebBrowser1").OLEFormat.Object .Object.Navigate2 _
"http://www.dh.gov.uk"

'
End Sub

"Joel" wrote:

Th eactive x form browser defaults to the workbook if not set to something
else.

"Atishoo" wrote:

thanks! still got same result might it be because im using a form webbrowser
not an active x webbrowser

"Joel" wrote:

Not sure why you aren't getting the address in the web box. This code works
for me.

Sub text()

End Sub
webaddress = ""
Set WebBar = Application.CommandBars("Web").Controls
For Each Item In WebBar
If Item.Type = msoControlComboBox Then
webaddress = Item.text
Exit For
End If

Next Item
Cells(ActiveCell.Row, "ar").Value = webaddress

End Sub


"Atishoo" wrote:

tried that last code and it seems to return the address of the whole excell
file (c:\folder\epb.xls) rather than the web page address

"Atishoo" wrote:

Is there no way to just return the web address in a cell?? i know how to set
the web address using navigate2! surely there must be a way to return the
address just as you would an objects value? then again maybe there isnt?

"Joel" wrote:

this will work. I'm not sure how to direrctly get the combox from the
command bar because it doesn't have a name. It is item 10 in my workbook but
not sure if that will always be the same item. You can also get all the web
addresses from the combobox if you need them.


Set WebBar = Application.CommandBars("Web").Controls
For Each Item In WebBar
If Item.Type = msoControlComboBox Then
webaddress = Item.Text
End If

Next Item

"Atishoo" wrote:

sorry i should have been more specific!
i meant the web address that the web box is currently viewing.

"Joel" wrote:

You have a few problems with the code below

1) A shape doesn't have an address. the location of the shape is determined
by 4 parameters which are points (or pixels) position.

left, top, width, height

2) If you have an Oleobject like a textbox, listbox, checkbox they have both
shape information and object information. The data inside the items will be
the Oleobjects.object while the picture type information will be shapes.

ActiveSheet.Oleobjects("WebBrowser2").object.Text - if item was a textbox

"Atishoo" wrote:

Hi how do I return a web browser address into a cell as per the following
example??


Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address