Microsoft
Software
Hardware
Network
Question : Error message suppression in word
Word produces an error message even though error handling code has been setup. Is this possible to suppress?
The macro is designed to open word documents on the server. It macro works fine when a document exists but if one is not found, an error number 1078 appears "This file could not be found".
The error message appears immediately after the line of code has been executed. The line that is prompting the error is as follows:
WordBasic.fileopen Name:=PathDir & "\Base Training\" & ComboBox1.Text & "_training_gradesheet.doc"
The code then continues down and runs the error handling code, giving a similar message "This file could not be found" I tried using 'Canceldisplay' but without success.
Answer : Error message suppression in word
you can create a file opener function that returns the doc if it's there and not íf it's not
Sub test()
Dim oDoc As Document
'get the doc by passing the path
Set oDoc = OpenFileTest(PathDir & "\Base Training\" & " " & "_training_gradesheet.doc"
)
'test for empty object
If oDoc Is Nothing Then Exit Sub
'do the rest of your processing with the oDoc object
MsgBox "hello"
'cleanup
Set oDoc = Nothing
End Sub
Public Function OpenFileTest(ByVal sfile As String) As Document
On Error GoTo errhandle
Application.DisplayAlerts = wdAlertsNone
Set OpenFileTest = WordBasic.fileopen(Name:=s
file)
Application.DisplayAlerts = wdAlertsAll
Exit Function
errhandle:
Err.Clear
Exit Function
End Function
hope this helps a bit
Random Solutions
HP, Pavilion, DV9548ca, XP downgrade; video drivers won't install
how use javascript to expand and close div tags in asp.net page
HP t5720 thin client boots to user automatically used to boot to admin. How do I change it back.
Problem using ActiveSync w/ Palm OS - SSL Certificates
What level of encryption is PPTP?
Microsoft, Windows , XP SP2, Task Scheduler - Open Browser without Window
Print a report with three colums by 4 rows and with duplex printing
Website Frame Question
reinstall and keep the raid configuration
Refresh rate possible for 100 Hz?