In message of Fri, 1 Aug 2014 03:31:38 in
microsoft.public.excel.programming, GS writes
How would I add 2003 to a machine running 2010. I have media for
2003,
but not for 2010.
What do you mean by "I have media for 2003"?
I mean I have Office 2003 on a disc.
My MSO11 Pro is on a disc. My MSO14 Pro is a download. Just install
I infer I can reload MS014,given a URL and some possible magic.;)
both, but the last install will become the default. If you want 2010 as
default then run 'Repair' in 'Programs and Features' to restore it as
default.
How do you select the version of Excel?
I use 'Freebar' from sourceforge! It's a VB6 replacement for the Office
Toolbar. I put a shortcut on there for whatever apps I want and just
select from there to run whatever version I want. Fortunately, each
version has a unique icon, making it easy to distinguish them. The
toolbar also displays a 'tooltip' when you hover over its icons.
Note that the usual notification about personal.xls being already open
displays when running more than 1 version.
You can get Freebar here...
http://freebar.sourceforge.net/en/
Thanks, that is likely to be REALLY useful.
I referred to some object model issues.
A long time ago, I wrote Sub ShowShapes() to dump ActiveSheet Shapes to
the Immediate Window. It does not work in 2010. I have commented On
Error calls to show some of the discrepancies.
I created a Macro to create a "Hello, World" textbox and added a call of
Showshapes to it.
In 2003, this is written to the Immediate Window.
1 shapes
Ix Name Shapetype Left,Top,Width,Height AM, AS, M(L, T, R, B) Text
1.0 Text Box 4 msoShapeRectangle 195,107.25,164.25,87 Tr, Fa, M(7.2,3.6,7.2,3.6) F(Regular,Arial,8): "Hello, World"
In 2011, I get a 1004 error, when I try to access
ActiveSheet.Shapes(1).TextFrame.AutoMargins
Without suppressing On Error statements, the code writes
1 shapes
Ix Name Shapetype Left,Top,Width,Height AM, AS, M(L, T, R, B) Text
1.0 Text Box 4 msoShapeRectangle 195,107.25,164.25,87 Tr, Fa, M(7.2,3.6,7.2,3.6)
I would value any insight into the deficiencies in my code.
In 2011, ActiveSheet.Shapes(1).TextFrame.AutoMargins shows in the Locals
Window as <Application-defined or object-defined error
I use shapes as I am given worksheets containing shapes. ;(
Option Explicit
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 01/08/2014 by IBM
'
'
If ActiveSheet.Shapes.Count < 0 Then ActiveSheet.Shapes(1).Delete
ActiveSheet.Shapes.AddTextbox(msoTextOrientationHo rizontal, 195#,
107.25, _
164.25, 87#).Select
Selection.Characters.Text = "Hello, World"
With Selection.Characters(Start:=1, Length:=12).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
ShowShapes
Stop
End Sub
Public Sub ShowShapes() ' Noddy to dump shapes on ActiveSheet
Dim GroupName As String
Dim i As Long, j As Long
Dim o As ShapeRange
Dim s As String
Dim Saved As Boolean
Dim v As Shape
Dim W As Shape
Saved = ActiveWorkbook.Saved
Debug.Print ActiveSheet.Shapes.Count & " shapes"
Debug.Print Left("Ix ", 6) & _
Left("Name" & " ", 14) & _
Left("Shapetype ", 19) & _
Left("Left,Top,Width,Height" & " ", 28) & _
"AM, AS, M(L, T, R, B) Text"
i = 0
For Each v In ActiveSheet.Shapes
i = i + 1
If Not v.Name Like "Group *" Then
Debug.Print ShapeLine(i, 0, v)
Else
GroupName = v.Name
' Can't analyse a group without destroying it
Debug.Print ShapeLine(i, 0, v) & "consists of " & _
v.GroupItems.Count & " items"
Set o = v.Ungroup
j = 0
For Each W In o
j = j + 1: Debug.Print ShapeLine(i, j, W)
Next W
o.Group ' Recreate group
' Restore default name V is destroyed by ungroup
ActiveSheet.Shapes(i).Name = GroupName
End If
Next v
ActiveWorkbook.Saved = Saved
End Sub
Private Function ShapeLine(ByVal Imain As Long, ByVal Isub As Long, _
ByVal v As Shape) As String
Dim ShapeType As String
Dim Text As String
ShapeType = TXAutoShapeType(v)
Text = ShapeText(v)
ShapeLine = Left(Imain & "." & Isub & " ", 6) & _
Left(v.Name & " ", 14) & _
Left(ShapeType, 19) & _
Left(v.Left & "," & v.Top & "," & v.Width & "," & _
v.Height & " ", 28) & _
Text
End Function
Private Function TXAutoShapeType(ByVal x As Shape) As String
Dim s As String
Select Case x.AutoShapeType
Case msoShapeMixed: s = "msoShapeMixed"
Case msoShapeRectangle: s = "msoShapeRectangle"
Case Else
Debug.Print "Untranslated AutoShapeType: " & x.AutoShapeType & _
"."
Debug.Print "cf. x.AutoShapeType in Locals window to get name"
Debug.Assert False ' Force error
End Select
s = Left(s & " ", 20)
TXAutoShapeType = s
End Function
Private Function ShapeText(ByVal v As Shape) As String
' On Error statements in this are suppressed.
Dim s As String
Dim i As Long
Dim j As Long
' On Error Resume Next
With v.TextFrame
'
' Crashes here with a 1004 as AutoMargins has invalid contents.
'
s = IIf(.AutoMargins, "Tr, ", "Fa, ") & _
IIf(.AutoSize, "Tr, ", "Fa, ")
s = s & "M(" & .MarginLeft & "," & .MarginTop & "," & _
.MarginRight & "," & .MarginBottom & ") "
With .Characters.Font
If Err.Number < 0 Then _
Exit Function ' Return empty string if no textframe
' On Error GoTo 0 ' Any errors now are fatal
s = s & "F(" & .FontStyle & "," & .Name & "," & _
.Size & "): """
End With
' On Error Resume Next
j = .Characters.Count
If Err.Number < 0 Then
' On Error GoTo 0 ' Any errors now are fatal
s = s & "NO TEXT"
Else
' On Error GoTo 0 ' Any errors now are fatal
' Text limits itself to 255 bytes
For i = 1 To j Step 255
s = s & .Characters(Start:=i).Text
Next i
End If
End With
s = s & """"
ShapeText = s
End Function
--
Walter Briscoe