-
Apr 9th, 2012, 03:36 PM
#1
Thread Starter
New Member
VBA Word Form with XML
Hello I am working with a Macro enabled document. I am not able to work as well with VBA and need a little help.
It errors out on some pcs, saying run-time error '4248': This command is not available because no document is open.
What is happening is that an error is occurring when this document is opened and additionally, it has some fields at the bottom which are hidden,
64-Case Military
65-Case Place of Death
66- Case Marital Status
67-Case Resident City Limits
68-Case Hispanic Origin
69-Case Dispositions
These six (6) fields above need to be populated from an XML document, which is not occurring at the present time.
-
Apr 11th, 2012, 01:22 PM
#2
Re: VBA Word Form with XML
You say "some PCs"....does that mean it works on some but not on others?
-
Apr 11th, 2012, 01:40 PM
#3
Thread Starter
New Member
Re: VBA Word Form with XML
Yes on the most recent versions of Word it works without a problem, the system says something like enable macros and the form populates without any issues whatsoever.
The code is like this:
Code:
Private Sub Document_Open()
Select Case ActiveDocument.FormFields("text64").Result
Case "Yes"
ActiveDocument.FormFields("Check1").CheckBox.Value = True
Case "No"
ActiveDocument.FormFields("Check2").CheckBox.Value = True
End Select
Select Case ActiveDocument.FormFields("text65").Result
Case "Inpatient"
ActiveDocument.FormFields("Check3").CheckBox.Value = True
Case "ER/Outpatient"
ActiveDocument.FormFields("Check4").CheckBox.Value = True
Case "DOA"
ActiveDocument.FormFields("Check5").CheckBox.Value = True
Case "Nursing Home"
ActiveDocument.FormFields("Check6").CheckBox.Value = True
Case "Hospice"
ActiveDocument.FormFields("Check7").CheckBox.Value = True
Case "Residence"
ActiveDocument.FormFields("Check8").CheckBox.Value = True
Case "Other"
ActiveDocument.FormFields("Check9").CheckBox.Value = True
End Select
Select Case ActiveDocument.FormFields("text66").Result
Case "Married"
ActiveDocument.FormFields("Check10").CheckBox.Value = True
Case "Never Married"
ActiveDocument.FormFields("Check11").CheckBox.Value = True
Case "Widowed"
ActiveDocument.FormFields("Check12").CheckBox.Value = True
Case "Divorced"
ActiveDocument.FormFields("Check13").CheckBox.Value = True
Case "Unknown"
ActiveDocument.FormFields("Check14").CheckBox.Value = True
End Select
Select Case ActiveDocument.FormFields("text67").Result
Case "Yes"
ActiveDocument.FormFields("Check15").CheckBox.Value = True
Case "No"
ActiveDocument.FormFields("Check16").CheckBox.Value = True
End Select
Select Case ActiveDocument.FormFields("text68").Result
Case "No"
ActiveDocument.FormFields("Check17").CheckBox.Value = True
Case "Yes"
ActiveDocument.FormFields("Check18").CheckBox.Value = True
End Select
Select Case ActiveDocument.FormFields("text69").Result
Case "Resomation"
ActiveDocument.FormFields("Check19").CheckBox.Value = True
Case "Burial"
ActiveDocument.FormFields("Check20").CheckBox.Value = True
Case "Cremation"
ActiveDocument.FormFields("Check21").CheckBox.Value = True
Case "Removal from State"
ActiveDocument.FormFields("Check22").CheckBox.Value = True
Case "Donation"
ActiveDocument.FormFields("Check23").CheckBox.Value = True
Case "Other (Specify)"
ActiveDocument.FormFields("Check24").CheckBox.Value = True
End Select
End Sub
What this code should be doing is taking values passed to it from an xml document and displaying a checkbox depending on the value that gets passed for items 64-69, which are the xml values getting passed. Depending on the word that gets passed in 64-69, it should check a box associated with the item. These passed values (items) appear on the form in the lower left hand corner of the form. The form is too big to send as an attachment, I am working on it. thanks, midani
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|