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 cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force Window to Open on Top

Status
Not open for further replies.

KYLE06716

Mechanical
Joined
Jun 18, 2013
Messages
10
Location
US
I have a VBA code in excel to bring up the GAL (Global Address List) from Outlook, through word since excel doesn't have the functionality.

The problem is that the GAL window is opening below the excel window. It is causing problems for users with a single monitor setup, because it locks out the excel page, and they cant get to the GAL window. I think the problem may be due to the fact that outlook is already running, so it is opening on the same plane as outlook, which may be underneath the excel spreadsheet.

Is there a way to make the GAL window open on top?

Private Sub CommandButton1_Click()

Dim objWordApp As Object
Dim strCode As String
Dim strAddress As String
Dim lngDoubleCR As Long
'Set up the formatting codes in strCode
strCode = "<PR_DISPLAY_NAME>"

' As GetAddress is not available in MS Excel, a call to MS Word object
' has been made to borrow MS Word's functionality
Application.DisplayAlerts = False
'On Error Resume Next
' Set objWordApp = New Word.Application
Set objWordApp = CreateObject("Word.Application")
strAddress = objWordApp.GetAddress(, strCode, False, 1, , , True, True)
objWordApp.Quit
Set objWordApp = Nothing
On Error GoTo 0
Application.DisplayAlerts = True

' Nothing was selected
If strAddress = "" Then Exit Sub

strAddress = Right(strAddress, Len(strAddress))

'Eliminate blank paragraphs by looking for two carriage returns in a row
lngDoubleCR = InStr(strAddress, vbNewLine & vbNewLine)
Do While lngDoubleCR <> 0
strAddress = Left(strAddress, lngDoubleCR - 1) & Mid(strAddress, lngDoubleCR + 1)
lngDoubleCR = InStr(strAddress, vbNewLine & vbNewLine)
Loop

TextBox1.Text = strAddress

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top