Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Closing a word file?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

' Linking Word Documents to certain cells within the LM_INDEX
' Code written by:
' Paul Goodale
' ------------


' Declaring Variables

Dim intResponse As Integer
Dim WrdApp As Object
Dim Msg, Style, Title

On Error GoTo Ignore

Cell = Target

'Declaring Variables for the Message Box
Msg = "Would you like to view " & Target & " ?"
Style = vbYesNo + vbQuestion
Title = "Open BOM file"

If Left(Target, 2) = "LM" Then
frmOpenLM.Show vbModal
Exit Sub

' Determines whether the cell has a BOM# within it
ElseIf Left(Target, 3) = "BOM" Then

' Displays a message box with variable options
intResponse = MsgBox(Msg, Style, Title)

' Selects the outcome if 'Yes' is chosen
If intResponse = vbYes Then

Set WrdApp = CreateObject("Word.Application")

' Opens Word file
With WrdApp

' Searches for Errors
On Error GoTo DisplayErrorMsg

' Prints out the BOM# Word file
..Documents.Open Filename:="S:\XBS\Technical
Support\TechnicalSupport\Letter Maintenance\BOM\BOM - GISC\" & Target,
ReadOnly:=False
End With

WrdApp.Visible = True

' If a Target is printed the Error Message is ignored
GoTo Ignore

End If

' Ignores all if user selects vbNo
If intResponse = vbNo Then GoTo Ignore

'Ignores all other cells except BOM#
Else: GoTo Ignore

End If


DisplayErrorMsg:
MsgBox "The file " & Target & " could not be found.",
vbExclamation, "File Not Found"
Exit Sub


Igno
Exit Sub



End Sub


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
create hyperlink from exel file to particular word in word file Hiten Kapasi Excel Discussion (Misc queries) 1 May 15th 10 11:58 AM
How to skip the save file notoification on file closing? Dan Excel Worksheet Functions 1 August 19th 07 02:26 PM
Turn Off save prompt, reminder when closing modified WORD... S. Nyman New Users to Excel 5 June 30th 06 01:23 PM
mail merge-word file automatically closing vishu Excel Discussion (Misc queries) 3 October 24th 05 05:03 PM
Excel code to Wait until Word finishes printing before closing Mike Molyneaux[_2_] Excel Programming 2 October 24th 03 02:45 AM


All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"