Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
create hyperlink from exel file to particular word in word file | Excel Discussion (Misc queries) | |||
How to skip the save file notoification on file closing? | Excel Worksheet Functions | |||
Turn Off save prompt, reminder when closing modified WORD... | New Users to Excel | |||
mail merge-word file automatically closing | Excel Discussion (Misc queries) | |||
Excel code to Wait until Word finishes printing before closing | Excel Programming |