Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a project

Status
Not open for further replies.

GP1

Programmer
Jan 15, 2002
23
0
0
NO
Hi,
I have done vb and asp projects before. Today my bos gave me a new asignment of that has to be done on a word document, so I gues this meens vba.
The requirements are that the user just creates his/her doc then later for the headings on the document he can add url that will popup an ie window and go to the particular site.
Also he wants all the headings on the document to be listed on the top of the dument with book marks to the heading. With a back button from the heading to the top of the document.
Please dont think I am trying to use you to get this done. I only want to know whether this can be done. And the how I can go around to do this.

Thanks,
Gavin
 
Hi GP1

I have something that might help but it's in Excel and not Word. The user choose the cell with the URL and click a button to bring out the IE windows.

Sub AutomateIE()

Dim ie As Object
Dim result As Integer
Dim myRow As Integer, myCol As Integer
Dim myURL As String
'
' Get activecell value, must be a valid
' web address
'

myRow = ActiveCell.Row
myCol = ActiveCell.Column
myURL = ActiveSheet.Cells(myRow, myCol)
'
' Set up the Automation object
'

Set ie = CreateObject("InternetExplorer.Application")
'
' Navigate to a page and customize the browser window
'

ie.Navigate " & myURL
ie.Toolbar = False ' }set these to true if you want to have the
ie.StatusBar = False ' }toolbar, statusbar and menu visible
ie.MenuBar = False
'
' keep itself busy while the page loads
'

Do While ie.Busy
DoEvents
Loop
'
' Display page info
'

result = MsgBox( _
"Current URL: " & ie.LocationURL & vbCrLf & _
"Current Title: " & ie.LocationName & vbCrLf & _
"Document type: " & ie.Type & vbCrLf & vbCrLf & _
"Would you like to view this document?", _
vbYesNo + vbQuestion)

If result = vbYes Then
'
' If Yes, make browser visible
'

ie.Visible = True
Else
'
' If no, quit
'

ie.Quit
End If

Set ie = Nothing

End Sub

Hope this maybe of some help to you.

rgrds
LSTAN
 
Thanks,
I'll try this. Meen while can direct me to any tutorials etc.. that I can use.

Thanks,
Gavin
 
LSTAN,
Thanks because of your help I already started coding. Can you tell me if there is a place to declare and define global variable in VBA.

eg:-
Dim globalBookMarCounter As Integer
globalBookMarCounter = 0

This is important as I have to increase the globalBookMarCounter before I use it.

Thanks,
Gavin
 
Hi Garvin

In VBA, if you want all the modules, procedures to have access to a variable, you use the Public keyword.

eg.

Public globalBookMarCounter As Integer


but if you only want the variable to be access by one module only then just declare the variable at the General section of the module.

Hope I explain clearly because I am not good at explaining things.

rgrds
LSTAN
 
Hi,
Thanks, but I want to be able to initialize "globalBookMarCounter = 0" only one time. Like in VB you have the

Private Sub Form_Load()
End Sub

Is there any way of doing this ?

Thanks,
Gavin
 
Hi

Just declare it at the General section of the form code pane.

Dim globalBookMarCounter As Integer


Private Sub Form_Load()
globalBookMarCounter = 0
End Sub


Hope this is what you are refering.

rgrds
LSTAN
 
Not exactly I want to initialize some variables when I open any document.

Thanks,
Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top