Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-01-2018, 08:42 AM
ksor ksor is offline Why error when starting up word from Access Windows 10 Why error when starting up word from Access Office 2016
Advanced Beginner
Why error when starting up word from Access
 
Join Date: Feb 2018
Location: Århus V, Denmark
Posts: 78
ksor is on a distinguished road
Default Why error when starting up word from Access

I try start up word from Access by VBA and use this code:

Code:
    Dim objWord As Word.Application
    Dim bigDoc As Word.Document
    Dim WordHeaderFooter As HeaderFooter
    If IsAppRunning("Word.Application") Then Set objWord = GetObject("Word.Application") Else Set objWord = CreateObject("Word.Application")
    Set bigDoc = objWord.Documents.add
    objWord.Visible = True
    With bigDoc
        .Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "Alle registrerede data vedr. PersonId: " & _
                                         Me.PersonID & " " & HentFMENavn(Me.PersonID)
        .Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = "Dokumentet er sammensat pr. " & _
                       StrConv(Format(Date, "dddd"), vbProperCase) & " den " & Date
    End With
When Word is NOT running it works fine !

When word is running (not document open) is gives me bad syntaks:

???????? Where is my screendump, it was here when I wrote the message ??????

What is wrong here ?

EDIT: It seems like ONLY this is needed:
Set objWord = GetObject(, "Word.Application")

Last edited by ksor; 02-01-2018 at 11:36 AM.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message when starting Outlook 2007 WalterW Outlook 10 07-26-2015 11:16 AM
Error when starting Word & Excel mango Word 0 08-15-2013 07:53 AM
Help with error upon starting Outlook chrisj Outlook 1 02-21-2012 08:55 PM
Help finding starting point on project (Excel/Access?) ndk415 Office 1 06-19-2011 03:28 AM
Error Starting MS Help Renee Hendershott Office 0 01-22-2006 03:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft