-
WSjasonsas
AskWoody LoungerHi mlwonio and Andrew,
Here is the code I’m using to open the template:
Set wdapp = CreateObject(“Word.Application”) ‘Create an instance of Word
wdapp.Documents.Add Template:=TemplatePath & TemplateName ‘Open the template the user has chosen
Set ActiveTemplate = wdapp.ActiveDocument ‘Set the ‘ActiveTemplate’ variableAt the end of the sub I use this line:
ActiveTemplate.AttachedTemplate = “”
The document I’m opening is definitely saved as a Word Template. If I check the value of ‘AttachedTemplate’ before I get to that line, it’s set to the value of the template they’ve opened. If I check it just after that line execute, I get “Normal.dot”.
Admittedly I’ve been testing this locally on my PC, but these are the results I’m getting:
– If I try to open the template just before I execute ‘ActiveTemplate.AttachedTemplate = “”‘, the template is marked as ‘Read-Only’
– If I try to open the template just after I execute ‘ActiveTemplate.AttachedTemplate = “”‘, the template is marked as ‘Read-Only’
– If I try to open the template after I close the document I’ve generated, the template is NOT marked as ‘Read-Only’Does it matter that I’m testing this locally on my PC? Ie, I’m still trying to open the template on the same PC I’ve generated the document, even though I’ve set the ‘AttachedTemplate’ to “”.
-
WSjasonsas
AskWoody LoungerI’ve tested setting the attachtemplate to “” this morning but the underlying template still appears as read only until I close the document that I created. Any suggestions?
-
WSjasonsas
AskWoody LoungerThanks Andrew for replying.
When you say that ‘if you set it to nothing, you are actually attaching the ‘Normla template”, what does that actually mean for the document itself? Will it not appear correctly?
-
WSjasonsas
AskWoody LoungerHI Gary, that’s exactly what it was. Thanks for your help, problem is now resolved.
-
WSjasonsas
AskWoody LoungerHi John,
I’ve changed the design slightly because each case is now able to have multiple offences. Please see the new attachment for the updated design. It still works basically the same way in that I would still create records in tblCaseOffencePeriodLine using a Listbox drawing values from tblOffencePeriod. I haven’t added more fields to the tblCaseOffencePeriodLine but would need to add two more fields to hold offence date and due date.
Cheers,
-
WSjasonsas
AskWoody LoungerOk, I’ve gotten a little further with this. I’ve added a sub-form based on the tblCaseOffencePeriodLine table. This allows users to choose the offence period and it automatically fills in the related case ID, which is what I want. However I want to restrict the periods they can select from based on the type of offence they chose on the form. Eg, Offence 1 might relate to periods 1999, 2000, 2001. Offence 2 might relate to periods ‘Quarter ending March 2010’, ‘Quarter ending June 2010’. So as they fill in the offence type on the form, I want to restrict the values they see on the sub-form. Does that make sense? Is this possible?
Cheers,
Jason -
WSjasonsas
AskWoody LoungerHi John,
I thought it might be a bit hard to explain in an email. I’ve attached a relationship diagram. I’m quite new to access, so maybe my relationships aren’t set up correctly? Hope this helps.
Cheers,
Jason -
WSjasonsas
AskWoody LoungerThankyou so much John, that works perfectly. Much appreciated!
-
WSjasonsas
AskWoody LoungerThanks for all the help guys, much appreciated!
-
WSjasonsas
AskWoody LoungerYes you can move controls via code without switching to Design view.
Hi John,
Are you able to point me in the right direction for this as far as code goes? I’m actually thinking of using this for another question I just posted about whether to use 2 tables for ‘individuals’ and ‘corporations’. For example, if a user wishes to create a new ‘client’, I currently have a drop down box which lets them select ‘individual’ or ‘client’. Depending on what they choose, I want to unhide and hide and also move controls around dynamically.
cheers,
Jason -
WSjasonsas
AskWoody LoungerAnother way is to move the controls around on the form by setting the Left and Top Properties as needed.
Hi Bob,
Am I able to do this ‘dynamically’? By that I mean, without putting the form into design view, moving the fields around and then redisplaying the form?
Cheers,
Jason -
WSjasonsas
AskWoody LoungerHi bob,
I thought about this, but one of the reasons I thought about not doing this was that depending on where teh controls were created on the form in the first place, they would appear in different spots as others were hidden or unhidden. (Eg, one control might appear at the top of the form while another might in the bottom right.
Is there a way around this?
Cheers,
Jason -
WSjasonsas
AskWoody LoungerHi Kent,
Thanks for that tip. I’m assuming I would have a query that runs that when the user selects a template, it would search a table to find which variables relate to a particular template.
On the sub-form, would I need to build the form which shows all the variables and then use the query to show only the variables I want? Or am I able to (and is it better) to build the form ‘dynamically’ (Eg, only build the form once the user selects which template they want to use?)
Cheers,
Jason -
WSjasonsas
AskWoody LoungerHi kentg,
when I say modify, I mean that I want them to enter a value for these variables. Eg, different start/end dates, different case numbers etc.
Would I need to have a different form for each template? The number of templates could be over 100 – is there an easier way to do this?
Cheers,
Jason -
WSjasonsas
AskWoody LoungerHi John,
Yes, I want it so that the user cannot view clients from other states. I’ve actually got the form already based on a query, but how do I modify it so that the query looks up the ‘ChosenState’ from what the user selected?
Cheers,
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

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
-
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
33 minutes ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
1 hour, 50 minutes ago -
The story of Windows Longhorn
by
Cybertooth
2 hours, 19 minutes ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
3 hours, 48 minutes ago -
Are manuals extinct?
by
Susan Bradley
4 minutes ago -
Canonical ditching Sudo for Rust Sudo -rs starting with Ubuntu
by
Alex5723
12 hours, 56 minutes ago -
Network Issue
by
Casey H
1 minute ago -
Fedora Linux is now an official WSL distro
by
Alex5723
1 day ago -
May 2025 Office non-Security updates
by
PKCano
1 day, 1 hour ago -
Windows 10 filehistory including onedrive folder
by
Steve Bondy
1 day, 3 hours ago -
pages print on restart (Win 11 23H2)
by
cyraxote
4 hours, 10 minutes ago -
Windows 11 Insider Preview build 26200.5581 released to DEV
by
joep517
1 day, 5 hours ago -
Windows 11 Insider Preview build 26120.3950 (24H2) released to BETA
by
joep517
1 day, 5 hours ago -
Proton to drop prices after ruling against “Apple tax”
by
Cybertooth
1 day, 12 hours ago -
24H2 Installer – don’t see Option for non destructive install
by
JP
5 hours, 15 minutes ago -
Asking Again here (New User and Fast change only backups)
by
thymej
2 days ago -
How much I spent on the Mac mini
by
Will Fastie
23 hours, 38 minutes ago -
How to get rid of Copilot in Microsoft 365
by
Lance Whitney
3 hours, 16 minutes ago -
Spring cleanup — 2025
by
Deanna McElveen
2 days, 6 hours ago -
Setting up Windows 11
by
Susan Bradley
1 day, 1 hour ago -
VLC Introduces Cutting-Edge AI Subtitling and Translation Capabilities
by
Alex5723
2 days, 1 hour ago -
Powershell version?
by
CWBillow
2 days, 2 hours ago -
SendTom Toys
by
CWBillow
13 hours, 17 minutes ago -
Add shortcut to taskbar?
by
CWBillow
2 days, 6 hours ago -
Sycophancy in GPT-4o: What happened
by
Alex5723
2 days, 22 hours ago -
How can I install Skype on Windows 7?
by
Help
2 days, 21 hours ago -
Logitech MK850 Keyboard issues
by
Rush2112
2 days, 4 hours ago -
We live in a simulation
by
Alex5723
3 days, 12 hours ago -
Netplwiz not working
by
RetiredGeek
2 days, 23 hours ago -
Windows 11 24H2 is broadly available
by
Alex5723
4 days, 1 hour 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.