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

insert file as link in Outlook 2000

Status
Not open for further replies.

crabback

Technical User
Jan 29, 2007
64
IE
hey

I wonder can anyone help me. I'm trying to write a macro that allows a user to browse for a file and then inserts the file path and name as a link in an emails body.

I have code in a function (but I don't think it will work) that opens an instance of Word openfile dialog, and allows user to browse and select the file. The problem is that the function returns empty! Any help? Thanks

This is my code:
Function GetFolderPathWithWord()
Dim objWord As Word.Application
Dim dlg As Object 'Dialogs.wdDialogFileOpen
Dim lngWidth As Long
Dim lngHeight As Long
Dim objOL As Outlook.Application
Dim objOLWindow As Object

On Error Resume Next

' get active Outlook window
Set objOL = CreateObject("Outlook.Application")
Set objOLWindow = objOL.ActiveWindow

' start Word if necessary
Set objWord = GetObject(, "Word.Application")
If objWord Is Nothing Then
Set objWord = CreateObject("Word.Application")
End If
If Not objWord Is Nothing Then
' get current Word window dimensions
lngWidth = objWord.Width
lngHeight = objWord.Height
' reduce size of Word window
objWord.Width = 0
objWord.Height = 0
' switch to Word
objWord.Activate

' show file dialog and handle users choice
Set dlg = objWord.Dialogs(wdDialogFileOpen)
With dlg
.InitialView = msoFileDialogViewList
If .Display <> 0 Then
GetFolderPathWithWord = dlg.SelectedItems(1)
Else
GetFolderPathWithWord = "User cancelled dialog"
End If
End With
Else
GetFolderPathWithWord = "Could not open Word"
End If


Crabback
 
you can use a common dialog such as openFile to get the file path, your trouble comes in where to place / run the procedure from.

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top