Humig Postado Novembro 26, 2009 Denunciar Share Postado Novembro 26, 2009 Salve srs. , comecei com VBA ainda agora então basicamente estou "brincando" com o codigo para aprender !Minha duvida : porque o codigo 1 abaixo funciona e o cod. 2 não ? As diferencas estão em negrito.O cod.2 retorna mensagem : "Run time error 4605" "Function is not available". Agradeço qualquer ajudaHuCod. 1Dim odoc As Word.Document Dim otb1 As Table Dim otb2 As Table Dim opr1 As Paragraph Dim opr2 As Paragraph Dim opr3 As Paragraph Dim opr4 As Paragraph Dim opr5 As Paragraph Dim opr6 As Paragraph Dim rng1 As Range Dim rng2 As Range Dim rng3 As Range Dim rng4 As Range Dim rng5 As Range Dim rng6 As Range Dim crng1 As Range Dim srng As Range Dim osl1 As Selection Dim osl2 As Selection Dim csel As Selection Dim ofld As Field Set odoc = Word.Documents.Add 'odoc.PageSetup.Orientation = wdOrientLandscape odoc.PageSetup.TopMargin = CentimetersToPoints(2.5) odoc.PageSetup.BottomMargin = CentimetersToPoints(1.5) odoc.PageSetup.LeftMargin = CentimetersToPoints(2) odoc.PageSetup.RightMargin = CentimetersToPoints(2) odoc.PageSetup.Gutter = CentimetersToPoints(0) odoc.PageSetup.HeaderDistance = CentimetersToPoints(1) odoc.PageSetup.FooterDistance = CentimetersToPoints(1) Set opr1 = odoc.Paragraphs.Add Set rng1 = opr1.Range Set otb1 = odoc.Tables.Add(Range:=rng1, NumRows:=3, NumColumns:= _ 2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitFixed) otb1.Borders.OutsideLineStyle = wdLineStyleSingle 'otb1.Borders.InsideLineStyle = wdLineStyleNone otb1.Columns.Item(1).PreferredWidth = 350 otb1.Columns.Item(2).PreferredWidth = 100 otb1.Cell(1, 1).Range.Font.Name = "Kozuka Gothic Pro M" otb1.Cell(1, 1).Range.Font.Size = 12 otb1.Cell(1, 1).Range.InsertAfter (" LYC DO BRASIL ") Selection.MoveRight (wdCell) otb1.Cell(1, 2).Range.Font.Name = "Arial" otb1.Cell(1, 2).Range.Font.Size = 10 ''otb1.Cell(1, 2).Range.Select Set ofld = otb1.Cell(1, 2).Range.Fields.Add(Selection.Range, -1, "AUTOTEXT ""Página X de Y"" ", True) Cod. 2Dim odoc As Word.Document Dim otb1 As Table Dim otb2 As Table Dim opr1 As Paragraph Dim opr2 As Paragraph Dim opr3 As Paragraph Dim opr4 As Paragraph Dim opr5 As Paragraph Dim opr6 As Paragraph Dim rng1 As Range Dim rng2 As Range Dim rng3 As Range Dim rng4 As Range Dim rng5 As Range Dim rng6 As Range Dim crng1 As Range Dim srng As Range Dim osl1 As Selection Dim osl2 As Selection Dim csel As Selection Dim ofld As Field Set odoc = Word.Documents.Add 'odoc.PageSetup.Orientation = wdOrientLandscape odoc.PageSetup.TopMargin = CentimetersToPoints(2.5) odoc.PageSetup.BottomMargin = CentimetersToPoints(1.5) odoc.PageSetup.LeftMargin = CentimetersToPoints(2) odoc.PageSetup.RightMargin = CentimetersToPoints(2) odoc.PageSetup.Gutter = CentimetersToPoints(0) odoc.PageSetup.HeaderDistance = CentimetersToPoints(1) odoc.PageSetup.FooterDistance = CentimetersToPoints(1) Set opr1 = odoc.Paragraphs.Add Set rng1 = opr1.Range Set otb1 = odoc.Tables.Add(Range:=rng1, NumRows:=3, NumColumns:= _ 2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitFixed) otb1.Borders.OutsideLineStyle = wdLineStyleSingle 'otb1.Borders.InsideLineStyle = wdLineStyleNone otb1.Columns.Item(1).PreferredWidth = 350 otb1.Columns.Item(2).PreferredWidth = 100 otb1.Cell(1, 1).Range.Font.Name = "Kozuka Gothic Pro M" otb1.Cell(1, 1).Range.Font.Size = 12 otb1.Cell(1, 1).Range.InsertAfter (" LYC DO BRASIL ") 'Selection.MoveRight (wdCell) otb1.Cell(1, 2).Range.Font.Name = "Arial" otb1.Cell(1, 2).Range.Font.Size = 10 otb1.Cell(1, 2).Range.Select Set ofld = otb1.Cell(1, 2).Range.Fields.Add(Selection.Range, -1, "AUTOTEXT ""Página X de Y"" ", True) Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
Humig
Salve srs. , comecei com VBA ainda agora então basicamente estou "brincando" com o codigo para aprender !
Minha duvida : porque o codigo 1 abaixo funciona e o cod. 2 não ? As diferencas estão em negrito.
O cod.2 retorna mensagem : "Run time error 4605" "Function is not available".
Agradeço qualquer ajuda
Hu
Cod. 1
Dim odoc As Word.Document
Dim otb1 As Table
Dim otb2 As Table
Dim opr1 As Paragraph
Dim opr2 As Paragraph
Dim opr3 As Paragraph
Dim opr4 As Paragraph
Dim opr5 As Paragraph
Dim opr6 As Paragraph
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
Dim rng5 As Range
Dim rng6 As Range
Dim crng1 As Range
Dim srng As Range
Dim osl1 As Selection
Dim osl2 As Selection
Dim csel As Selection
Dim ofld As Field
Set odoc = Word.Documents.Add
'odoc.PageSetup.Orientation = wdOrientLandscape
odoc.PageSetup.TopMargin = CentimetersToPoints(2.5)
odoc.PageSetup.BottomMargin = CentimetersToPoints(1.5)
odoc.PageSetup.LeftMargin = CentimetersToPoints(2)
odoc.PageSetup.RightMargin = CentimetersToPoints(2)
odoc.PageSetup.Gutter = CentimetersToPoints(0)
odoc.PageSetup.HeaderDistance = CentimetersToPoints(1)
odoc.PageSetup.FooterDistance = CentimetersToPoints(1)
Set opr1 = odoc.Paragraphs.Add
Set rng1 = opr1.Range
Set otb1 = odoc.Tables.Add(Range:=rng1, NumRows:=3, NumColumns:= _
2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed)
otb1.Borders.OutsideLineStyle = wdLineStyleSingle
'otb1.Borders.InsideLineStyle = wdLineStyleNone
otb1.Columns.Item(1).PreferredWidth = 350
otb1.Columns.Item(2).PreferredWidth = 100
otb1.Cell(1, 1).Range.Font.Name = "Kozuka Gothic Pro M"
otb1.Cell(1, 1).Range.Font.Size = 12
otb1.Cell(1, 1).Range.InsertAfter (" LYC DO BRASIL ")
Selection.MoveRight (wdCell)
otb1.Cell(1, 2).Range.Font.Name = "Arial"
otb1.Cell(1, 2).Range.Font.Size = 10
''otb1.Cell(1, 2).Range.Select
Set ofld = otb1.Cell(1, 2).Range.Fields.Add(Selection.Range, -1, "AUTOTEXT ""Página X de Y"" ", True)
Cod. 2
Dim odoc As Word.Document
Dim otb1 As Table
Dim otb2 As Table
Dim opr1 As Paragraph
Dim opr2 As Paragraph
Dim opr3 As Paragraph
Dim opr4 As Paragraph
Dim opr5 As Paragraph
Dim opr6 As Paragraph
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
Dim rng5 As Range
Dim rng6 As Range
Dim crng1 As Range
Dim srng As Range
Dim osl1 As Selection
Dim osl2 As Selection
Dim csel As Selection
Dim ofld As Field
Set odoc = Word.Documents.Add
'odoc.PageSetup.Orientation = wdOrientLandscape
odoc.PageSetup.TopMargin = CentimetersToPoints(2.5)
odoc.PageSetup.BottomMargin = CentimetersToPoints(1.5)
odoc.PageSetup.LeftMargin = CentimetersToPoints(2)
odoc.PageSetup.RightMargin = CentimetersToPoints(2)
odoc.PageSetup.Gutter = CentimetersToPoints(0)
odoc.PageSetup.HeaderDistance = CentimetersToPoints(1)
odoc.PageSetup.FooterDistance = CentimetersToPoints(1)
Set opr1 = odoc.Paragraphs.Add
Set rng1 = opr1.Range
Set otb1 = odoc.Tables.Add(Range:=rng1, NumRows:=3, NumColumns:= _
2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed)
otb1.Borders.OutsideLineStyle = wdLineStyleSingle
'otb1.Borders.InsideLineStyle = wdLineStyleNone
otb1.Columns.Item(1).PreferredWidth = 350
otb1.Columns.Item(2).PreferredWidth = 100
otb1.Cell(1, 1).Range.Font.Name = "Kozuka Gothic Pro M"
otb1.Cell(1, 1).Range.Font.Size = 12
otb1.Cell(1, 1).Range.InsertAfter (" LYC DO BRASIL ")
'Selection.MoveRight (wdCell)
otb1.Cell(1, 2).Range.Font.Name = "Arial"
otb1.Cell(1, 2).Range.Font.Size = 10
otb1.Cell(1, 2).Range.Select
Set ofld = otb1.Cell(1, 2).Range.Fields.Add(Selection.Range, -1, "AUTOTEXT ""Página X de Y"" ", True)
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.