How to open Word from Access

  • Thread starter Thread starter Fio Koller
  • Start date Start date
F

Fio Koller

Hi there
Does anybody know how to open Word properly from Access?

Since we switched to Office 2003 this will not work anymore:

On Error Resume Next
AppActivate "Microsoft Word"
Set WordObj = GetObject(, "Word.Application")


Maybe I should take out most this following lines which may not be needed
anymore:


If Err = 429 Then
If Application.IsCompiled = False Then 'Bei A-97, das NICHT MDE sein darf:
Programm-Pfad
Shell "C:\Programme\Microsoft Office\Office\WINWORD.EXE", 3 'A97
vbMaximizedFocus) '=im Vollbild öffnen 19.05.01 Das ist es!!!
ElseIf Application.IsCompiled = True Then 'Bei A-XP: Programm-Pfad
Shell "C:\Programme\Microsoft Office\Office10\WINWORD.EXE", 3 'XP
vbMaximizedFocus) '=im Vollbild öffnen 19.05.01 Das ist es!!!
End If

If Application.IsCompiled = False Then 'Bbei A-97,
MsgBox "Diese Pause, weil Word für die folgenden Anweisungen zu
langsam öffnet. Bitte quittieren."
Else 'A-XP braucht die Pause nicht mehr (je nach Betriebssystem)
End If
AppActivate "Microsoft Word" ', -1 ', -1 'crosoft Word" ', 0 ', -1
'WordObj 'AnwID '"Microsoft Word" 'sichert, dass kein Code ausgeführt wird,
bis "Word" vollständig geladen ist
End If
On Error GoTo 0 'damit wird die vorherige Anweisung "On Error Resume Next"
ausser Kraft gesetzt
' Switches to Word when it is allready open
Set WordObj = GetObject(, "Word.Application") 'Verweis auf ein Application
Objekt, auf die Kopie von Word, die gerade offen ist
With WordObj ' Do all following comands on behalf of object Wordobj
'.Visible = False ' Make word not visible
.Run MacroName:="KPF2"
'.Visible = True ' Make word visible
End With ' WordObj


Many thanks in advance
Regards, fio
 
This is an alternative way, if opening specific documents, that does not
care what the path to the executable is:



Function OpenWordDocGen(strDocName As String)
Dim ObjApp As Object
'opens the doc
Set ObjApp = CreateObject("Word.application")
ObjApp.Visible = True
ObjApp.Documents.Open strDocName
End Function

Bob Galway
 
Thank you so much!
I believe this version suits me more since Word is not installed at my PC
but at the server from our office-network.
Will have time and the chance to test between Christmas and New Year.
Merry Christmas, Fio
 
Back
Top