Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / July 2008

Tip: Looking for answers? Try searching our database.

web box address

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Atishoo - 22 Jul 2008 09:47 GMT
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
Joel - 22 Jul 2008 11:14 GMT
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

> 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
Atishoo - 22 Jul 2008 11:21 GMT
sorry i should have been more specific!
i meant the web address that the web box is currently viewing.

> You have a few problems with the code below
>
[quoted text clipped - 13 lines]
> >
> > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Joel - 22 Jul 2008 12:01 GMT
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

> sorry i should have been more specific!
> i meant the web address that the web box is currently viewing.
[quoted text clipped - 16 lines]
> > >
> > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 22 Jul 2008 14:31 GMT
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?

> 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
[quoted text clipped - 29 lines]
> > > >
> > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 22 Jul 2008 14:55 GMT
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

> 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
[quoted text clipped - 33 lines]
> > > > >
> > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Joel - 22 Jul 2008 15:11 GMT
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

> 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
[quoted text clipped - 36 lines]
> > > > > >
> > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 22 Jul 2008 20:11 GMT
thanks! still got same  result might it be because im using a form webbrowser
not an active x webbrowser

> Not sure why you aren't getting the address in the web box.  This code works
> for me.
[quoted text clipped - 55 lines]
> > > > > > >
> > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Joel - 22 Jul 2008 22:17 GMT
Th eactive x form browser defaults to the workbook if not set to something
else.

> thanks! still got same  result might it be because im using a form webbrowser
> not an active x webbrowser
[quoted text clipped - 58 lines]
> > > > > > > >
> > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 23 Jul 2008 12:53 GMT
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.Explorer.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

> Th eactive x form browser defaults to the workbook if not set to something
> else.
[quoted text clipped - 61 lines]
> > > > > > > > >
> > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Joel - 23 Jul 2008 14:13 GMT
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

> Oh this problem is driving me nuts!
> Maybe this might shed some light?
[quoted text clipped - 90 lines]
> > > > > > > > > >
> > > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 23 Jul 2008 17:25 GMT
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!

> What is this statement doing?
>
[quoted text clipped - 99 lines]
> > > > > > > > > > >
> > > > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Joel - 23 Jul 2008 21:02 GMT
Again the statement below isn't a good statement.  You have two equal
statements with an OR .  what is the Or doing.  There is no "IF".  Correct
this statement!

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

> 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
[quoted text clipped - 108 lines]
> > > > > > > > > > > >
> > > > > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 24 Jul 2008 14:53 GMT
But that statement is only part of a macro used to create and place the web
box it doesnt have any current role in my workbook, and it is not a working
part of the macro but a direction to the user, that statement aside the web
boxes are in place and working i just cant retrieve the web address

> Again the statement below isn't a good statement.  You have two equal
> statements with an OR .  what is the Or doing.  There is no "IF".  Correct
[quoted text clipped - 115 lines]
> > > > > > > > > > > > >
> > > > > > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Joel - 24 Jul 2008 16:22 GMT
I think you are getting the filename as the default browser addrress because
yuo never changed it.  some of you code is dependant on the value of
BrowserPresent (there is an IF stement using this value) and I'm not sure
what the value is set to.  fix the obvious problems before you look at the
more difficult problems.  You never know how bad lines of code are effecting
the rest of your code.

> But that statement is only part of a macro used to create and place the web
> box it doesnt have any current role in my workbook, and it is not a working
[quoted text clipped - 120 lines]
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 24 Jul 2008 17:33 GMT
hm! didnt think of it that way! ill have a crack tonight!
thanks John

> I think you are getting the filename as the default browser addrress because
> yuo never changed it.  some of you code is dependant on the value of
[quoted text clipped - 127 lines]
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 25 Jul 2008 17:13 GMT
Nope its no blinkin good! kept it simple as possible! just added a browser
manually from the control toolbox to a blank workbook set the address via
navigate 2 on a workbook open event and still I cant get the bloomin
displayed site url to return!
what the heck am i doing wrong ??? i have an idea though! I work on the 4th
floor and its one heck of a drop for a computer!

> I think you are getting the filename as the default browser addrress because
> yuo never changed it.  some of you code is dependant on the value of
[quoted text clipped - 127 lines]
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
Atishoo - 25 Jul 2008 20:01 GMT
Yeah!!
think I may not have explained myself at all properly Have just sussed it
this doe the trick:-

Cells(ActiveCell.Row, "ar").Value = Me.WebBrowser2.LocationURL

thanks John

> Again the statement below isn't a good statement.  You have two equal
> statements with an OR .  what is the Or doing.  There is no "IF".  Correct
[quoted text clipped - 115 lines]
> > > > > > > > > > > > >
> > > > > > > > > > > > > Cells(ActiveCell.Row, "ar").Value = ActiveSheet.Shapes("WebBrowser2").Address
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.