D
Deleted member 147267
Guest
Since you've gone this far, it would not be hard to pass it an invalid file name to test my suggestion?I do not know why it is not working either.
Since you've gone this far, it would not be hard to pass it an invalid file name to test my suggestion?I do not know why it is not working either.
Hi Micron,Since you've gone this far, it would not be hard to pass it an invalid file name to test my suggestion?
You declare a variable wdDoNotSaveChanges as an implicit Variant. I guess this is because you are using late-binding.
O/P has done?Declare the variable
oDoc
Set oWord = CreateWord
oWord.Visible = True
Dim oDoc As Object
Yes, they are spread all over.Ahh, Didn't see that on the original code, must have missed it.
Option Explicit
Option Compare Database
Private m_oWord As Object
Function GetWord(blVisible As Boolean) As Object
On Error Resume Next
If Not m_oWord Is Nothing Then
Set m_oWord = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set m_oWord = CreateObject("Word.Application")
End If
End If
Set GetWord = m_oWord
End Function
Function ReleaseWord() As Boolean
If Not m_oWord Is Nothing Then
Set m_oWord = Nothing
End If
ReleaseWord = m_oWord Is Nothing
End Function
CreateWord()
with GetWord()
. When done with the object just make a call to ReleaseWord()
Exit_MayCauseAnError:
Screen.MousePointer = 0
Exit Sub
ErrHandler:
'I don't know why Error 424 keeps popping up every 3 or 4 button presses but this is a workaround to try creating word again.
If Err.Number = 424 Then
Call LogError("RenewalsForComms ChaseAdminButton", False)
Debug.Print "Error 424"
Set oWord = CreateWord(True)
Set oDoc = oWord.Documents.Add("F:\whatever.dotx")
Resume Next
Else
LogError ("RenewalsForComms ChaseAdminButton")
Resume Exit_MayCauseAnError
End If
Dim strFilename As String
strFilename = "F:\whatever.dotx"
Set oDoc = oWord.Documents.Add(strFilename)