Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2012, 07:50 AM
coconutt coconutt is offline ckBox automation Windows XP ckBox automation Office 2007
Novice
ckBox automation
 
Join Date: May 2012
Posts: 10
coconutt is on a distinguished road
Default ckBox automation


Hello, I have a docx (protected) when a user clicks a ckbox after tabbing out another automatically checks as well. Version two of the document I added more to the docx and made it landscape to accommodate the new column. The issue I am having is when i click on the new column ckbox and tab, the mirrored ckbox doesn't check like the other columns.
Her is what I run on exit:

Code:
Sub MyMacro()
Dim ffld As Word.FormField
Dim rw As Row
 
Set rw = Selection.Rows(1)
rw.Cells(4).Range.FormFields(1).CheckBox.Value = rw.Cells(1).Range.FormFields(1).CheckBox.Value
End Sub
any thoughts on how to get this to work on the other column?
Attached Files
File Type: docx LabOrder.docx (36.8 KB, 11 views)

Last edited by macropod; 08-31-2012 at 05:54 PM. Reason: Added code tags
Reply With Quote
  #2  
Old 08-31-2012, 06:13 PM
macropod's Avatar
macropod macropod is offline ckBox automation Windows 7 64bit ckBox automation Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi coconutt,

The issue is that your macro is only designed to update the 4th column from the 1st column's result. Try:
Code:
Sub MyMacro()
Application.ScreenUpdating = False
Dim TblRow As Long, TblCol As Long
With Selection
  TblRow = .Cells(1).RowIndex
  TblCol = .Cells(1).ColumnIndex
  .Tables(1).Cell(TblRow, TblCol + 3).Range.FormFields(1).CheckBox.Value = _
    .Tables(1).Cell(TblRow, TblCol).Range.FormFields(1).CheckBox.Value
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-04-2012, 07:41 AM
coconutt coconutt is offline ckBox automation Windows XP ckBox automation Office 2007
Novice
ckBox automation
 
Join Date: May 2012
Posts: 10
coconutt is on a distinguished road
Default thanks

That works, thank you so much.
Reply With Quote
  #4  
Old 09-10-2012, 01:01 PM
coconutt coconutt is offline ckBox automation Windows XP ckBox automation Office 2007
Novice
ckBox automation
 
Join Date: May 2012
Posts: 10
coconutt is on a distinguished road
Default

Thanks for the reply, when i use this code i get a run-time error 5941. The requested member of the collection does not exist. Any thoughts?
Reply With Quote
  #5  
Old 09-10-2012, 05:27 PM
macropod's Avatar
macropod macropod is offline ckBox automation Windows 7 64bit ckBox automation Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You're probably calling the macro from a formfield it was never meant to be called from. It should only be called from checkbox formfields for which there is a corresponding checkbox formfield two columns to the right.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 09-11-2012, 12:17 PM
coconutt coconutt is offline ckBox automation Windows XP ckBox automation Office 2007
Novice
ckBox automation
 
Join Date: May 2012
Posts: 10
coconutt is on a distinguished road
Default

hmm, I thought I had the correct ckBox form field? Please see attatched
Attached Files
File Type: docx Doc2.docx (26.0 KB, 8 views)
Reply With Quote
  #7  
Old 09-11-2012, 04:22 PM
macropod's Avatar
macropod macropod is offline ckBox automation Windows 7 64bit ckBox automation Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi coconutt,

I added the macro I posted to your previous attachment and checked its performance on every checkox formfield. None of the checkboxes in column 1 or your added column 6 threw an error and the corresponding checkboxes in columns 4 and 9 updated correctly.

The only anomolies concerned items 1016, 1180 and 15610 at the bottom of the first column. There, I believe, none of the checkboxes should trigger the on-exit function - and all of the checkboxes should be enabled (allow manual update). However, some of those checkboxes do trigger the macro and some are not enabled. Triggering of the macro from a column other than 1 on those rows generates the error.

For those three rows, you could trigger the following macro from column1 (to ensure columns 3 & 4 are cleared if column 1 is cleared):
Code:
Sub ClearChks()
Application.ScreenUpdating = False
Dim TblRow As Long, TblCol As Long
With Selection
  TblRow = .Cells(1).RowIndex
  TblCol = .Cells(1).ColumnIndex
  If .Tables(1).Cell(TblRow, TblCol).Range.FormFields(1).CheckBox.Value = False Then
    .Tables(1).Cell(TblRow, TblCol + 3).Range.FormFields(1).CheckBox.Value = False
    .Tables(1).Cell(TblRow, TblCol + 4).Range.FormFields(1).CheckBox.Value = False
  End If
End With
Application.ScreenUpdating = True
End Sub
And, to ensure only one of the checkboxes in columns 3 & 4 on those rows can be checked (and even then, only if column 1 is checked):
Code:
Sub ExclusiveCheck()
Application.ScreenUpdating = False
Dim TblRow As Long, TblCol As Long, iOffset As Long
With Selection
  TblRow = .Cells(1).RowIndex
  TblCol = .Cells(1).ColumnIndex
  If .Tables(1).Cell(TblRow, 1).Range.FormFields(1).CheckBox.Value = False Then
    .Tables(1).Cell(TblRow, TblCol).Range.FormFields(1).CheckBox.Value = False
    Exit Sub
  End If
  If TblCol = 4 Then iOffset = 1 Else iOffset = -1
  .Tables(1).Cell(TblRow, TblCol + iOffset).Range.FormFields(1).CheckBox.Value = _
    Not .Tables(1).Cell(TblRow, TblCol).Range.FormFields(1).CheckBox.Value
End With
Application.ScreenUpdating = True
End Sub
See attached.
Attached Files
File Type: zip LabOrder.zip (43.8 KB, 12 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
word automation, word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
ckBox automation Document automation coconutt Word 1 05-02-2012 01:45 PM
Automation Word-Excel stephen_pen Mail Merge 0 09-22-2011 05:17 PM
ckBox automation Urgent help regarding automation. aligahk06 Excel 1 01-14-2010 01:55 PM
What is Application Automation and How can I use it in VBA KramerJ Excel 0 03-30-2009 12:59 PM
COM Automation Errors ivanm Word 0 03-23-2009 07:02 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:39 PM.


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