-
WSTroyWells
AskWoody LoungerI’m certain no VB expert, but I’m learning. I came across a similar problem on a VBA application I was building.
For me it ended up being some corruption. I was able to overcome it by exporting all my forms and modules, and then reimporting them into a new document (importing into a new project for VB, I guess).
Hope that helps!!
Troy -
WSTroyWells
AskWoody LoungerOctober 28, 2001 at 6:34 pm in reply to: Populating text box based on option button (Word 2000 VBA) #549028I can’t believe it was that simple. Yes, moving the UserForm1.Show to the last step solved my problem.
F.Y.I., the reason I was using variables is simply because they already existed and are set by the click event on the object buttons for other reasons within the larger application (which I did not include in the sample).
Thanks so much for your help!!
Troy -
WSTroyWells
AskWoody LoungerOctober 22, 2001 at 11:06 am in reply to: Insert a document object with relative path (Word 2000 VBA) #547896I wanted to reply for the information of others, since I found this answer on another newsgroup.
From “Cindy Meister -WordMVP-” <CindyMeister@swissonline.ch
It's quite understandable why a method that inserts an object
wants to have a full path. Is your issue picking up the file
from a relative location? Then use ActiveDocument.Path & "" &
"Filename"So the new code that works for me is:
Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8", FileName _
:=ActiveDocument.Path & "" & "Object.doc", LinkToFile:=False, DisplayAsIcon _
:=FalseEnjoy!!
Troy -
WSTroyWells
AskWoody LoungerOctober 3, 2001 at 11:39 am in reply to: Exiting a Parent sub from a child sub (Word 2000 VBA) #545141What I was doing was bringing up a message box and deselecting a check box if one of three option buttons was not selected (they all start out false). The key to getting this down was your idea that setting the check box value to false was initiating the Click event. That is exactly what was happening. The following is my solution. Feel free to improve upon it, but this does work as I had hoped.
NOTE: I did not include the function (which I changed to a sub) called “IsDocumentTypeSelected”. This function set’s a variable (DocumentTypeSelected) if it determines that none of the option buttons have been set to True.
Private Sub cbxAddCoverCopyright_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
IsDocumentTypeSelected
If DocumentTypeSelected = False Then
MsgBox “You must select a document type before setting options.”
Cancel = True
Exit Sub
End If
End SubPrivate Sub cbxAddCoverCopyright_Click()
If cbxAddCoverCopyright.Value = True Then
frmOptionsCoverCopyright.Show
PopulateCoverOptionControlsFromVariables
End If
End SubBy using the MouseDown event to check the status of the variable, I did not even have to set the checkbox value to false. I could then follow this with the Click event if the variable was true. For some strange but wonderful reason, if the MouseDown event found the variable to be false, the Click event never happened.
Thanks for all the help!!
Troy -
WSTroyWells
AskWoody LoungerOctober 2, 2001 at 5:41 pm in reply to: Exiting a Parent sub from a child sub (Word 2000 VBA) #545036I guess I should have mentioned that this is but a small piece of a much larger project. The variable you mentioned is a public boolean variable in a separate module. I just forgot to include it with the code I posted.
I’ll take into consideration getting rid of the “Set”. Thanks for the insightful input!!
The main issue now is getting only one instance of the message box to show up. Everything else seems to work.
Thanks for your help!!
Troy -
WSTroyWells
AskWoody LoungerOctober 2, 2001 at 2:31 pm in reply to: Exiting a Parent sub from a child sub (Word 2000 VBA) #545015I’m fairly new at this stuff so bear with me. I’ll try to answer your questions amidst the code below:
Private Sub cbxAddCoverCopyright_Click()
‘The following line of code is where I am calling the function for the first (and I thought only) time.
SetDocumentType‘The following line of code is where I am setting getting the Result of the function.
Result = SetDocumentType()‘Next I use the result in an If..Then statement.
If Result = False Then“cbxAddCoverCopyright” is a check box. If setting the value to false is considered a click, HOW DO I GET AROUND THAT?
cbxAddCoverCopyright.Value = False
MsgBox “You must select a document type before setting options.”
Cancel = True
Exit Sub
End If
….
End Sub
——————————————————————————–
Public Function SetDocumentType()
If frmFormatDocumentMain.obBusinessDocument.Value = False And _
frmFormatDocumentMain.obTechnicalDocument.Value = False And _
frmFormatDocumentMain.obUserDocument.Value = False Then
SetDocumentType = False
End If
End FunctionThanks again for your help!!
Troy -
WSTroyWells
AskWoody LoungerOctober 2, 2001 at 10:02 am in reply to: Exiting a Parent sub from a child sub (Word 2000 VBA) #544971That seems to work fine (and thanks so much for pointing my in the right programming direction), EXCEPT why would my MsgBox appear twice? I have to click OK or hit ENTER twice to get rid of it. I have included the code I am using below.
Thanks again for your help!!
TroyPrivate Sub cbxAddCoverCopyright_Click()
SetDocumentType
Result = SetDocumentType()
If Result = False Then
cbxAddCoverCopyright.Value = False
MsgBox “You must select a document type before setting options.”
Cancel = True
Exit Sub
End If
….
End Sub
——————————————————————————–
Public Function SetDocumentType()
If frmFormatDocumentMain.obBusinessDocument.Value = False And _
frmFormatDocumentMain.obTechnicalDocument.Value = False And _
frmFormatDocumentMain.obUserDocument.Value = False Then
SetDocumentType = False
End If
End Function -
WSTroyWells
AskWoody LoungerSeptember 22, 2001 at 6:33 pm in reply to: Inserting, opening, and closing an object > IPF (Word 2000 VBA) #543695F.Y.I. just in case this happens to you, I thought I would share what appears to be the fix for this, even though I don’t know for sure the cause. Perhaps there was some document corruption.
I ended up exporting all my forms and modules, and then importing them into a new clean document. The new document does not exhibit the errors of the other document.
Hope this helps someone else!!
Troy -
WSTroyWells
AskWoody LoungerSeptember 19, 2001 at 11:25 am in reply to: Adding all headings to a list box (VBA for Word 2000) #543106That did the trick. Thanks!!
I actually can get out of testing if I am in the heading by going to the very end of the document
Selection.EndKey Unit:=wdStory
and then running this code. Since the last item in the document is not likely to be a heading (unlike the first item), this code should work just fine.
Thanks again for the help!!
Troy -
WSTroyWells
AskWoody LoungerSeptember 19, 2001 at 2:23 am in reply to: Adding all headings to a list box (VBA for Word 2000) #543077Yes!! You were exactly right. I changed this in one of my fruitless attempts to get my code to work and forgot to change it back. It works fine now.
However, now that my list box contains the lists, I cannot seem to do the next step. I want to find (and select) the selected item (heading) in the list after I click OK. I have tried the following code, but it does not seem to work.
Private Sub cmbOK_Click()
Dim i As Integer
For i = lbAppxHeadings.ListCount – 1 To 0 Step -1
If lbAppxHeadings.Selected(i) = True Then
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToAbsolute, Count:=i
Exit For
End If
Next i
End SubThanks for any help you can give!!
Troy -
WSTroyWells
AskWoody LoungerSeptember 18, 2001 at 1:25 am in reply to: Adding all headings to a list box (VBA for Word 2000) #542887This is what I am trying, but still I get nothing:
Private Sub frmAppendixStartsat_Initialize()
Dim DocumentHeadings As Variant, i As Integer
DocumentHeadings = ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)
For i = 1 To UBound(DocumentHeadings)
lbAppxHeadings.AddItem DocumentHeadings(i)
Next i
End SubWhat am I missing?
Thanks again!!
Troy -
WSTroyWells
AskWoody LoungerSeptember 18, 2001 at 12:04 am in reply to: Adding all headings to a list box (VBA for Word 2000) #542868Thanks again for your response. Unfortunately, that code doesn’t seem to do anything.
Also, to answer your question, the main thing I need to do after I select a heading and click OK is to find that particular heading. Once found I will format the heading with a specific style, adjust numbering, etc. If I can just populate the list, select the heading and then find it, I can take it from there.
Thanks!!
Troy -
WSTroyWells
AskWoody LoungerSeptember 17, 2001 at 9:30 pm in reply to: Adding all headings to a list box (VBA for Word 2000) #542830Thanks for your reply. I found the statement:
myHeadings = ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)
but could never figure out how to use it properly to collect all the headings and put them in a list. I will need to select a heading and then perform some functions on it afterward. I probably am just lacking the syntax to do this properly. I’m very much a newbie when it come to arrays as well. This may be part of my problem.
Regarding:
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToNext, count:=1, Name:=””
I still need to understand what to do to populate my list box. I would also need to make sure I could find it again later to perform the functions I need to on what I select.
Thanks again for your help!!
Troy -
WSTroyWells
AskWoody LoungerSeptember 9, 2001 at 8:47 pm in reply to: Creating textbox/spinbuttons for characters/digits (VBA for Word 2000) #541530This did the trick. I learned a lot through studying your code and making a few modifications here and there. Thanks for taking the time!!
Troy
-
WSTroyWells
AskWoody LoungerSeptember 9, 2001 at 12:30 am in reply to: Creating textbox/spinbuttons for characters/digits (VBA for Word 2000) #541472Thanks so much for your response. This did work for me.
However, as I am in learning mode, I did have a couple of questions and one additional request
:
Question 1: What is the purpose or function of the following line in the code you gave me:
q = Int(AlphaNumber / 26)
Question 2: What is the purpose or function of the following line in the code you gave me:
TextBox2.Value = Chr(64 + q) & Chr(65 + AlphaNumber – q * 26)
Request 1: As much as I appreciated your suggestions for disabling the text box for user input, I actually want users to be able to manually input, as well as use spinbuttons. However, when I tried to do this using the code you gave below (I only changed the variable names to protect the somewhat innocent) and then used a spin button, it only accepted the value of the spinbutton. I tried putting the following code in the change event for the text box:
SpinButton1.Value=TextBox1.Value
but that didn’t seem to do anything. If you could provide this extra bit of information, I’d sure appreciate it.
Thanks!!
Troy
![]() |
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 |

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
-
two pages side by side land scape
by
marc
6 minutes ago -
Deleting obsolete OneNote notebooks
by
afillat
1 hour, 49 minutes ago -
Word/Outlook 2024 vs Dragon Professional 16
by
Kathy Stevens
1 hour, 59 minutes ago -
Security Essentials or Defender?
by
MalcolmP
2 hours, 3 minutes ago -
April 2025 updates out
by
Susan Bradley
7 minutes ago -
Framework to stop selling some PCs in the US due to new tariffs
by
Alex5723
4 hours, 15 minutes ago -
WARNING about Nvidia driver version 572.83 and 4000/5000 series cards
by
Bob99
4 hours, 17 minutes ago -
Creating an Index in Word 365
by
CWBillow
15 hours, 44 minutes ago -
Coming at Word 365 and Table of Contents
by
CWBillow
15 hours, 49 minutes ago -
Windows 11 Insider Preview Build 22635.5170 (23H2) released to BETA
by
joep517
20 hours, 45 minutes ago -
Has the Microsoft Account Sharing Problem Been Fixed?
by
jknauth
1 day ago -
W11 24H2 – Susan Bradley
by
G Pickerell
1 day, 2 hours ago -
7 tips to get the most out of Windows 11
by
Alex5723
1 day ago -
Using Office apps with non-Microsoft cloud services
by
Peter Deegan
17 hours, 29 minutes ago -
I installed Windows 11 24H2
by
Will Fastie
6 hours, 9 minutes ago -
NotifyIcons — Put that System tray to work!
by
Deanna McElveen
1 day, 5 hours ago -
Decisions to be made before moving to Windows 11
by
Susan Bradley
2 minutes ago -
Port of Seattle says ransomware breach impacts 90,000 people
by
Nibbled To Death By Ducks
1 day, 13 hours ago -
Looking for personal finance software with budgeting capabilities
by
cellsee6
22 hours, 1 minute ago -
ATT/Yahoo Secure Mail Key
by
Lil88reb
22 hours, 15 minutes ago -
Devices with apps using sprotect.sys driver might stop responding
by
Alex5723
2 days, 6 hours ago -
Neowin – 20 times computers embarrassed themselves with public BSODs and goofups
by
EP
2 days, 15 hours ago -
Slow Down in Windows 10 performance after March 2025 updates ??
by
arbrich
1 day, 17 hours ago -
Mail from certain domains not delivered to my outlook.com address
by
pumphouse
1 day, 23 hours ago -
Is data that is in OneDrive also taking up space on my computer?
by
WShollis1818
2 days, 10 hours ago -
Nvidia just fixed an AMD Linux bug
by
Alex5723
4 days, 2 hours ago -
50 years and counting
by
Susan Bradley
1 day ago -
Fix Bluetooth Device Failed to Delete in Windows Settings
by
Drcard:))
1 day, 3 hours ago -
Licensing and pricing updates for on-premises server products coming July 2025
by
Alex5723
4 days, 13 hours ago -
Edge : Deprecating window.external.getHostEnvironmentValue()
by
Alex5723
4 days, 13 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.