I
IUnderstandSomething
I have made a code that works fine with me running Office 2003, but
crash in the customers setup running Office 2000 and only RunTime
Access 2000. What do I need to change?
The code is run from a form module in Access trying to connect to a
Word-document:
**************************************************************
Private Sub Journal_DblClick(Cancel As Integer)
With Me!Journal
.Enabled = True
.Locked = False
.Class = "Word.Application"
.Verb = acOLEVerbOpen
.Action = acOLEActivate
End With
InsertField
Feil:
End Sub
Private Sub btnNewJournal_Click()
'On Error GoTo wordfeil
Me!Journal.SetFocus
With Me!Journal
.Enabled = True
.Locked = False
If .OLEType <> acOLENone Then
MsgBox "There is already a journal."
GoTo slutt
End If
.Class = "Word.Application"
'.OLETypeAllowed = acOLEEmbedded
'.SourceDoc = vPath & "\NyJournal.doc"
.Verb = acOLEVerbOpen
.Action = acOLECreateEmbed
.Action = acOLEActivate
End With
InsertField
slutt:
Exit Sub
wordfeil:
MsgBox Err.Number & vbCr & Err.Description
Exit Sub
End Sub
Public Function InsertBookmark(vBook, vTekst As String)
On Error GoTo Err_InsertBookmark
With Me!Journal
.Object.Application.Selection.GoTo what:=wdGoToBookmark,
Name:=vBook
.Object.Application.Selection.TypeText Text:=vTekst
End With
Exit Function
Err_InsertBookmark:
If Err = 5101 Then 'No bookmark
MsgBox "No bookmark"
Else
MsgBox Err.Description
End If
Exit Function
End Function
Private Sub InsertField()
Dim x
On Error GoTo feilfelt
x = InsertBookmark("Kategori", "JOURNAL" & vbCrLf &
UCase(Kategori))
x = InsertBookmark("Navn", Nz(Fornavn & " " & Etternavn, ""))
x = InsertBookmark("Adresse", Nz(Adresse, ""))
x = InsertBookmark("Født", Nz(Fødselsdato, ""))
x = InsertBookmark("Postnr", Nz(Postnummer, ""))
x = InsertBookmark("Poststed", Nz(Poststed, ""))
x = InsertBookmark("Sivilstand", Nz(Sivilstand, ""))
x = InsertBookmark("Pårørende", Nz(Pårørende, ""))
x = InsertBookmark("TlfPriv", Nz(TelefonPriv, ""))
x = InsertBookmark("TlfJobb", Nz(TelefonJobb, ""))
x = InsertBookmark("TlfMob", Nz(TelefonMobil, ""))
x = InsertBookmark("FastLege", Nz(LegeFast, ""))
x = InsertBookmark("TlfLege", Nz(TelefonLege, ""))
x = InsertBookmark("Anmerkninger", "Spesielle anmerkninger: " &
Anmerkninger & vbCrLf & vbCrLf)
x = InsertBookmark("Start", "")
Me!Journal.Object.Application.ActiveWindow.ActivePane.LargeScroll
Down:=-2
feilfelt:
Exit Sub
End Sub
********************************************************************
crash in the customers setup running Office 2000 and only RunTime
Access 2000. What do I need to change?
The code is run from a form module in Access trying to connect to a
Word-document:
**************************************************************
Private Sub Journal_DblClick(Cancel As Integer)
With Me!Journal
.Enabled = True
.Locked = False
.Class = "Word.Application"
.Verb = acOLEVerbOpen
.Action = acOLEActivate
End With
InsertField
Feil:
End Sub
Private Sub btnNewJournal_Click()
'On Error GoTo wordfeil
Me!Journal.SetFocus
With Me!Journal
.Enabled = True
.Locked = False
If .OLEType <> acOLENone Then
MsgBox "There is already a journal."
GoTo slutt
End If
.Class = "Word.Application"
'.OLETypeAllowed = acOLEEmbedded
'.SourceDoc = vPath & "\NyJournal.doc"
.Verb = acOLEVerbOpen
.Action = acOLECreateEmbed
.Action = acOLEActivate
End With
InsertField
slutt:
Exit Sub
wordfeil:
MsgBox Err.Number & vbCr & Err.Description
Exit Sub
End Sub
Public Function InsertBookmark(vBook, vTekst As String)
On Error GoTo Err_InsertBookmark
With Me!Journal
.Object.Application.Selection.GoTo what:=wdGoToBookmark,
Name:=vBook
.Object.Application.Selection.TypeText Text:=vTekst
End With
Exit Function
Err_InsertBookmark:
If Err = 5101 Then 'No bookmark
MsgBox "No bookmark"
Else
MsgBox Err.Description
End If
Exit Function
End Function
Private Sub InsertField()
Dim x
On Error GoTo feilfelt
x = InsertBookmark("Kategori", "JOURNAL" & vbCrLf &
UCase(Kategori))
x = InsertBookmark("Navn", Nz(Fornavn & " " & Etternavn, ""))
x = InsertBookmark("Adresse", Nz(Adresse, ""))
x = InsertBookmark("Født", Nz(Fødselsdato, ""))
x = InsertBookmark("Postnr", Nz(Postnummer, ""))
x = InsertBookmark("Poststed", Nz(Poststed, ""))
x = InsertBookmark("Sivilstand", Nz(Sivilstand, ""))
x = InsertBookmark("Pårørende", Nz(Pårørende, ""))
x = InsertBookmark("TlfPriv", Nz(TelefonPriv, ""))
x = InsertBookmark("TlfJobb", Nz(TelefonJobb, ""))
x = InsertBookmark("TlfMob", Nz(TelefonMobil, ""))
x = InsertBookmark("FastLege", Nz(LegeFast, ""))
x = InsertBookmark("TlfLege", Nz(TelefonLege, ""))
x = InsertBookmark("Anmerkninger", "Spesielle anmerkninger: " &
Anmerkninger & vbCrLf & vbCrLf)
x = InsertBookmark("Start", "")
Me!Journal.Object.Application.ActiveWindow.ActivePane.LargeScroll
Down:=-2
feilfelt:
Exit Sub
End Sub
********************************************************************