Runtime error 48, erro in loading DLL (1 Viewer)

Derek

Registered User.
Local time
Yesterday, 20:51
Joined
May 4, 2010
Messages
234
Hi guys,

I am getting a very strange error message . My code has been working fine without any issues for years but now I keep getting this error message. The error comes when I try to extract data from access form to the word document . Please see below the code:

Code:
Dim wa As New Word.Application
        Dim wd As Word.Document
        Dim bk As Word.Bookmark
        
        With wa             ' Error is coming at this line
            .Visible = True
            .Activate
            .ScreenUpdating = False
        End With

Any help will be much appreciated . Thanks
 

isladogs

MVP / VIP
Local time
Today, 04:51
Joined
Jan 14, 2017
Messages
18,209
Does it state which DLL is causing problems?

Check whether you have any references marked as MISSING - e.g. the Word reference library.
If so, browse to the location where the file is stored to fix it or change your code to use late binding so the reference isn't needed
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:51
Joined
Feb 28, 2001
Messages
27,131
As a simple attempt at a fix, open Access to that bit of code that you showed us.
From the code page's menu bar, follow Tools >> References.
Scroll through the checked items. Depending on which version of Office you are using, you might see Microsoft Word xx.x and a check-mark. It might or might not say "broken" or "missing."
If not checked, then check it. If checked, uncheck it. Then exit completely from Access. Open it again, go back that code, bring up the references list, and try to check the Word library.

How long ago did this stop working? If you go to the Settings section dealing with Windows Updates, you might look at your Update history to see if you have recently undergone an automated patch, which might have whacked Windows itself but ALSO could have whacked Office.

EDIT: Looks like Colin and I had similar ideas.
 

Derek

Registered User.
Local time
Yesterday, 20:51
Joined
May 4, 2010
Messages
234
Thanks - The code stopped working since few users got migrated to office 2013 . most users are on office 2010 and they are also getting the same issue now. I tried ticking andf unticking the references as suggested but no joy.

Now I tried few things , amended the code as below and it works until the yellow highlighted line(Set bk = WordDoc.Bookmarks("InsertTable") ). Just wondering can we change the insert table code with something similar (instead of bookmarks can we use soemthing else?)

Code:
If WordApp Is Nothing Then ' if word not called before
        Err.Clear   ' Clear Err object in case error occurred.
        Set WordApp = CreateObject("Word.Application")   'Start a new word application
    Else
        ' an instance of word has been created before
        On Error Resume Next 'Turn off error handling
        Err.Clear   ' Clear Err object in case error occurred.
        WordApp.Visible = False 'attempt to access previous instance of word
        If Err.Number <> 0 Then ' if instance of word no longer exists then create a new one
            Err.Clear   ' Clear Err object
            Set WordApp = CreateObject("Word.Application")   'Start a new word application
            On Error GoTo 0 'Revert to normal error  handling
        End If
    End If
    'Hide word (it will be made visible again CloseOrEditDocument or if an error occurs)
 
    WordApp.Visible = False
    WordApp.WindowState = 2
    WordApp.Visible = False

      
        'MsgBox strTemplatePath
        Set WordDoc = WordApp.Documents.Open(strTemplatePath & "FORM1.dotx")

        strTextFile = "aa"
      

      
        Set bk = WordDoc.Bookmarks("InsertTable") ' Here again I get error in loading DLL message .
      
        Dim wt As Word.Table, wr As Word.Row
        'Set wt = wd.Tables.Add(wd.Parent.Selection.Range, 1, 3)
        Set wt = wd.Tables.Add(bk.Range, 1, 4)
      
        wt.Columns(1).Width = 150
        wt.Columns(2).Width = 110
        wt.Columns(3).Width = 80
        wt.Columns(4).Width = 160
      
      '  RowFormat wt.Range, False
      
        Do Until .EOF
            'CurSec = Split(.Fields(0), ".")
            Set wr = wt.Rows.Add
          '  wr.Cells(1).Range.Text = CurSec(1) & "." & CurSec(2)
            wr.Cells(1).Range.Text = Nz(.Fields(0), "")
            wr.Cells(2).Range.Text = Nz(.Fields(1), "")
            wr.Cells(3).Range.Text = IIf(IsNull(.Fields(2)), "None", Format(.Fields(2), "dd/mm/yyyy"))
            wr.Cells(4).Range.Text = IIf(Nz(.Fields(3), 0) = 0, "Carried Forwards", "Date Closed: " & .Fields(3))
            .MoveNext
        Loop
        wt.Rows(1).Delete
      '  End If
    End With
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:51
Joined
Feb 28, 2001
Messages
27,131
OK, if you open that document with Word and attempt to do a GoTo Bookmark (i.e. doing it by hand), can you?
 

Derek

Registered User.
Local time
Yesterday, 20:51
Joined
May 4, 2010
Messages
234
Yes I can go to bookmark word document but the below line is giving error in loading DLL message:
Code:
Set bk = WordDoc.Bookmarks("InsertTable")
 

Users who are viewing this thread

Top Bottom