P
Peter
I wishfully underestimated the issues involved in getting a VBA applications
from the windows world to work under Mac Word 2004.
The following link is to an automated marking rubric. It is a table with
each row being a performance standard and the associated mark under a certain
criteria. The final column is used to store the mark the person is awarded.
The Windows interface is that the person clicks a button to show a floating
toolbar then clicks in a row for the assessed standard then clicks "Select
Standard" on the floating toolbar. This then shades the row and moves the
mark from the standard (in the first column) to the last column. There are
other buttons to "Unselect Standard" and also add and rescale the marks.
The document is stored at
http://www.usq.edu.au/users/evansp/browse/eMarking_Assistant/Marking_Rubric_unlocked.doc
The code is also shown below.
My questions are:
* how do I show the floating toolbar without usign a button in the document
* the floating toolbar should be modeless and how can I show it in this way
if .show vbmodeless throws an error on the Mac
* is there a clear description of the differences between Mac VBA and
WIndows VBA for Word.
Option Explicit
Public Sub ShowMarkingRubricToolbar()
'show the marking rubric toolbar
Dim UFrm As MarkingRubric
Set UFrm = New MarkingRubric
With UFrm
.Show
End With
End Sub
Sub addRescale()
On Error GoTo errorHandler
Selection.Tables(1).Select
'need to update the fields twice as easlier fields are based on values
in later fields
Selection.Fields.Update
Selection.Fields.Update
Exit Sub
errorHandler:
Debug.Print "Error # " & Str(Err.Number) & Err.Description
If Err.Number = 5941 Then
MsgBox "You must place your cursor in the marking rubric table you
want to update.", vbOKOnly
Else
MsgBox "Error # " & Str(Err.Number) & " " & Err.Description & "
Please send details to (e-mail address removed)", vbOKOnly
End If
End Sub
Sub selectStandard()
On Error GoTo errorHandler
Dim theresult As String
Dim theStandard As String
Dim theMark As String
Selection.HomeKey Unit:=wdRow
Selection.EndKey Unit:=wdRow, Extend:=True
theStandard = Selection.Text
theMark = Left(theStandard, (InStr(theStandard, " ") - 1))
If Not IsNumeric(theMark) Then
theresult = MsgBox("This standard does not have a mark as the first
word. Do you want to continue", vbYesNo)
If theresult = vbNo Then
Exit Sub
End If
End If
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorLightGreen
If IsNumeric(theMark) Then
Selection.EndKey Unit:=wdRow
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=theMark
End If
Exit Sub
errorHandler:
Debug.Print "Error # " & Str(Err.Number) & Err.Description
If Err.Number = 4605 Then
MsgBox "You must place your cursor in the row of the standard you
want to select.", vbOKOnly
Else
MsgBox "Error # " & Str(Err.Number) & " " & Err.Description & "
Please send details to (e-mail address removed)", vbOKOnly
End If
End Sub
Sub unselectStandard()
On Error GoTo errorHandler
Dim theStandard As String
Dim theMark As String
Selection.HomeKey Unit:=wdRow
Selection.EndKey Unit:=wdRow, Extend:=True
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorWhite
Selection.EndKey Unit:=wdRow
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=0
Exit Sub
errorHandler:
Debug.Print "Error # " & Str(Err.Number) & Err.Description
If Err.Number = 4605 Then
MsgBox "You must place your cursor in the row of the standard you
want to unselect.", vbOKOnly
Else
MsgBox "Error # " & Str(Err.Number) & " " & Err.Description & "
Please send details to (e-mail address removed)", vbOKOnly
End If
End Sub
from the windows world to work under Mac Word 2004.
The following link is to an automated marking rubric. It is a table with
each row being a performance standard and the associated mark under a certain
criteria. The final column is used to store the mark the person is awarded.
The Windows interface is that the person clicks a button to show a floating
toolbar then clicks in a row for the assessed standard then clicks "Select
Standard" on the floating toolbar. This then shades the row and moves the
mark from the standard (in the first column) to the last column. There are
other buttons to "Unselect Standard" and also add and rescale the marks.
The document is stored at
http://www.usq.edu.au/users/evansp/browse/eMarking_Assistant/Marking_Rubric_unlocked.doc
The code is also shown below.
My questions are:
* how do I show the floating toolbar without usign a button in the document
* the floating toolbar should be modeless and how can I show it in this way
if .show vbmodeless throws an error on the Mac
* is there a clear description of the differences between Mac VBA and
WIndows VBA for Word.
Option Explicit
Public Sub ShowMarkingRubricToolbar()
'show the marking rubric toolbar
Dim UFrm As MarkingRubric
Set UFrm = New MarkingRubric
With UFrm
.Show
End With
End Sub
Sub addRescale()
On Error GoTo errorHandler
Selection.Tables(1).Select
'need to update the fields twice as easlier fields are based on values
in later fields
Selection.Fields.Update
Selection.Fields.Update
Exit Sub
errorHandler:
Debug.Print "Error # " & Str(Err.Number) & Err.Description
If Err.Number = 5941 Then
MsgBox "You must place your cursor in the marking rubric table you
want to update.", vbOKOnly
Else
MsgBox "Error # " & Str(Err.Number) & " " & Err.Description & "
Please send details to (e-mail address removed)", vbOKOnly
End If
End Sub
Sub selectStandard()
On Error GoTo errorHandler
Dim theresult As String
Dim theStandard As String
Dim theMark As String
Selection.HomeKey Unit:=wdRow
Selection.EndKey Unit:=wdRow, Extend:=True
theStandard = Selection.Text
theMark = Left(theStandard, (InStr(theStandard, " ") - 1))
If Not IsNumeric(theMark) Then
theresult = MsgBox("This standard does not have a mark as the first
word. Do you want to continue", vbYesNo)
If theresult = vbNo Then
Exit Sub
End If
End If
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorLightGreen
If IsNumeric(theMark) Then
Selection.EndKey Unit:=wdRow
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=theMark
End If
Exit Sub
errorHandler:
Debug.Print "Error # " & Str(Err.Number) & Err.Description
If Err.Number = 4605 Then
MsgBox "You must place your cursor in the row of the standard you
want to select.", vbOKOnly
Else
MsgBox "Error # " & Str(Err.Number) & " " & Err.Description & "
Please send details to (e-mail address removed)", vbOKOnly
End If
End Sub
Sub unselectStandard()
On Error GoTo errorHandler
Dim theStandard As String
Dim theMark As String
Selection.HomeKey Unit:=wdRow
Selection.EndKey Unit:=wdRow, Extend:=True
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorWhite
Selection.EndKey Unit:=wdRow
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:=0
Exit Sub
errorHandler:
Debug.Print "Error # " & Str(Err.Number) & Err.Description
If Err.Number = 4605 Then
MsgBox "You must place your cursor in the row of the standard you
want to unselect.", vbOKOnly
Else
MsgBox "Error # " & Str(Err.Number) & " " & Err.Description & "
Please send details to (e-mail address removed)", vbOKOnly
End If
End Sub