sheas33
09-21-2010, 02:40 AM
Hello,
I'm new to this forum and to Vba, I usually record macros to lighten up my job but when I tried to do the same with word run-time errors started to pop up!
I have to go through some objects within a word document (which are excel tables), and open and close them as long as I select them. (then a program within the tables does another work)
but I tried to record and I cant deselect a table once opened...
or i cant select a second table...
my code is
Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Count:=1, Name:= _
"Excel.Sheet.8"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.ShapeRange(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Count:=1, Name:= _
"Excel.Sheet.8"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
I found a way to close the selection, but i cannot open a second table, run-time error 5941 appears
Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
ActiveWindow.SplitVertical = 55
ActiveWindow.SplitVertical = 100
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Count:=1, Name:= _
"Excel.Sheet.8"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
ActiveWindow.SplitVertical = 30
ActiveWindow.SplitVertical = 100
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Count:=1, Name:= _
"Excel.Sheet.8"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.ShapeRange(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
What can I do?
I'm new to this forum and to Vba, I usually record macros to lighten up my job but when I tried to do the same with word run-time errors started to pop up!
I have to go through some objects within a word document (which are excel tables), and open and close them as long as I select them. (then a program within the tables does another work)
but I tried to record and I cant deselect a table once opened...
or i cant select a second table...
my code is
Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Count:=1, Name:= _
"Excel.Sheet.8"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.ShapeRange(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Count:=1, Name:= _
"Excel.Sheet.8"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
I found a way to close the selection, but i cannot open a second table, run-time error 5941 appears
Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
ActiveWindow.SplitVertical = 55
ActiveWindow.SplitVertical = 100
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Count:=1, Name:= _
"Excel.Sheet.8"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
ActiveWindow.SplitVertical = 30
ActiveWindow.SplitVertical = 100
Selection.GoTo What:=wdGoToObject, Which:=wdGoToNext, Count:=1, Name:= _
"Excel.Sheet.8"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.ShapeRange(1).OLEFormat.DoVerb VerbIndex:=wdOLEVerbPrimary
What can I do?