From Access, I use automation to insert and format data into a Word doc. I use early binding and Set appWD = CreateObject(“Word.Application”). I set appWd to Nothing when finished, but leave the resulting doc open. This works just fine,
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Automation only works once (Access 2000)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Automation only works once (Access 2000)
- This topic has 8 replies, 3 voices, and was last updated 23 years, 6 months ago.
AuthorTopicWSPeter Kinross
AskWoody LoungerDecember 29, 2001 at 2:40 am #364635Viewing 0 reply threadsAuthorReplies-
WScharlotte
AskWoody LoungerDecember 29, 2001 at 3:28 am #560463You’re destroying the object variable but you’re leaving the application process itself open. Take a look at this thread and see if that information helps.
-
WSPeter Kinross
AskWoody LoungerDecember 29, 2001 at 10:34 am #560479Charlotte,
Thanks for the suggestions. I am now closing the document then setting appWd to nothing. I also am using the task-closing subroutine that you pointed to. I then open the doc using FollowHyperLink. After manually closing the doc, I still get the same error when I run the routine a second time!
Have a happy new year (I probably won -
WScharlotte
AskWoody Lounger -
WScharlotte
AskWoody Lounger -
WSPeter Kinross
AskWoody Lounger -
WSPeter Kinross
AskWoody LoungerDecember 30, 2001 at 10:30 am #560564Found the solution. Boy is it obtuse!
Using the line below causes another hidden instance of the Word object to start.
appWd.ActiveDocument.PageSetup TopMargin = CentimetersToPoints(2)
This hidden instance is not closed by
appWd.Quit
Set appWd = nothing
The solution:-
appWd.ActiveDocument.PageSetup TopMargin = appWd.CentimetersToPoints(2)Thanks all and a happy new year
-
WSClausParkhoi
AskWoody LoungerDecember 30, 2001 at 2:26 pm #560621Peter,
I have spent some time solving your problem, and now find that you have managed your self. Congratulatins!
I decided to post this anyway, since some of it might have your interest.Regards,
Claus ParkhoiHere it is:
I have done some changes to your code. The use of CentimetersToPoints was the
cause of your trouble. I have changed all refs to: appWd.CentimetersToPoints(x).
Furthermore I have made changes to attempt to use a running Wordapp by using
Getobject instead of Createobject. If Word is not running, Err_Tryword will
create the object for you and resume. This makes your function IsWordRunning
redundant.
I have tested it. It works. Happy New Year!
PS. Why don’t you put appWD declaration in the sub – I would have.Public appWD As Word.Application ‘In the real code this is actually declared elsewhere
Sub TryWord()
Dim StrToInsert As String, FileName As String, Msg As String
Dim blnWordWasRunning As Boolean
Dim FlDt As Date
On Error GoTo Err_TryWord
‘ ** remove blnWordWasRunning = IsWordRunning
‘ ** remove Set appWD = CreateObject(“Word.Application”)
‘ ** remove blnWordWasRunning = IsWordRunning
‘ insert next line
Set appWD = GetObject(, “Word.Application”) ‘ Use existing app, if any
FileName = “C:AAATemp.rtf”
With appWD
.Application.Visible = False
.Documents.Add DocumentType:=wdNewBlankDocument
With .Selection
.Font.Name = “Arial”
.Font.Size = 10
StrToInsert = “Hope This works”
.InsertAfter StrToInsert
End With ‘.Selection
With .ActiveDocument.PageSetup
.Orientation = wdOrientLandscape
.TopMargin = appWD.CentimetersToPoints(2)
.BottomMargin = appWD.CentimetersToPoints(1.5)
.LeftMargin = appWD.CentimetersToPoints(2)
End With ‘ActiveDocument.PageSetup
.Selection.ParagraphFormat.TabStops.ClearAll
.ActiveDocument.DefaultTabStop = appWD.CentimetersToPoints(1.27)
.Selection.ParagraphFormat.TabStops.Add Position:=appWD.CentimetersToPoints(2), _
Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
On Error Resume Next
FlDt = FileDateTime(FileName)
If Err.Number = 0 Then
On Error GoTo Err_TryWord
Msg = FileName & vbCrLf & “already exists.” & vbCrLf & _
“Overwrite – [Yes] or save as Temp.rtf – [No}”
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
FileName = “C:AAATemp2.rtf”
End If
End If
On Error GoTo Err_TryWord
.ActiveDocument.SaveAs FileName:=FileName, FileFormat:=wdFormatRTF
.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
‘ ** you might remove the next line, since calling again
.Quit
End With ‘appWD
Set appWD = Nothing
FollowHyperlink FileName
Exit_TryWord:
‘ ** remove the following lines
‘If blnWordWasRunning = False Then ‘| If word wasn’t already running
‘Do ‘| I -
WSPeter Kinross
AskWoody Lounger
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
I set up passkeys for my Microsoft account
by
Lance Whitney
3 hours, 14 minutes ago -
AI is for everyone
by
Peter Deegan
3 hours, 14 minutes ago -
Terabyte update 2025
by
Will Fastie
3 hours, 16 minutes ago -
Migrating from Windows 10 to Windows 11
by
Susan Bradley
3 hours, 37 minutes ago -
Lost sound after the upgrade to 24H2?
by
Susan Bradley
13 hours, 18 minutes ago -
How to move 10GB of data in C:\ProgramData\Package Cache ?
by
Alex5723
1 hour, 49 minutes ago -
Plugged in 24-7
by
CWBillow
21 hours, 35 minutes ago -
Netflix, Apple, BofA websites hijacked with fake help-desk numbers
by
Nibbled To Death By Ducks
1 day, 2 hours ago -
Have Copilot there but not taking over the screen in Word
by
CWBillow
23 hours, 36 minutes ago -
Windows 11 blocks Chrome 137.0.7151.68, 137.0.7151.69
by
Alex5723
2 days, 17 hours ago -
Are Macs immune?
by
Susan Bradley
15 hours, 39 minutes ago -
HP Envy and the Function keys
by
CWBillow
2 days, 1 hour ago -
Microsoft : Removal of unwanted drivers from Windows Update
by
Alex5723
5 hours, 9 minutes ago -
MacOS 26 beta 1 dropped support for Firewire 400/800
by
Alex5723
3 days, 5 hours ago -
Unable to update to version 22h2
by
04om
13 hours, 22 minutes ago -
Windows 11 Insider Preview Build 26100.4482 (24H2) released to Release Preview
by
joep517
3 days, 12 hours ago -
Windows 11 Insider Preview build 27881 released to Canary
by
joep517
3 days, 12 hours ago -
Very Quarrelsome Taskbar!
by
CWBillow
2 days, 22 hours ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
4 days, 1 hour ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
3 days, 14 hours ago -
Is your battery draining?
by
Susan Bradley
13 hours, 59 minutes ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
14 hours ago -
Weasel Words Rule Too Many Data Breach Notifications
by
Nibbled To Death By Ducks
4 days, 5 hours ago -
Windows Command Prompt and Powershell will not open as Administrator
by
Gordski
7 hours, 45 minutes ago -
Intel Management Engine (Intel ME) Security Issue
by
PL1
3 days, 13 hours ago -
Old Geek Forced to Update. Buy a Win 11 PC? Yikes! How do I cope?
by
RonE22
3 days, 6 hours ago -
National scam day
by
Susan Bradley
2 days, 12 hours ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
3 days, 9 hours ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
5 days, 6 hours ago -
Tools to support internet discussions
by
Kathy Stevens
3 days, 19 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.