Ir para conteúdo
Fórum Script Brasil
  • 0

Vba - Excel


Guest Guest

Pergunta

Olá pessoal, gostaria de saber como eu finalizo minha rotina em VB. A rotina executa alguns comandos no excel e eu quero que ela finalize com a opção de Salvar Como e que também saia do Excel! Eu estou tentanto finalizar esta rotina, mas quando eu executo a macro e a Guia de Salvar Como aparece e seleciona-se Cancelar, aparece um erro, e depura meu código... Aguardo alguma ajuda...

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0
Guest - stralo -

Dae, cara aki está minha macro...

ela configura um documento nos moldes da ABNT, pelo menos parte dele.

O final do código pode ser útil...Lá tem a rotina q usei de tratamento de erro.

qualquer coisa poste outro mensagem

falow!

Sub congig()

'

' congig Macro

' Macro gravada 09/02/05 por Juliano Kazapi

'

CommandBars("Standard").Visible = False

CommandBars("Formatting").Visible = False

ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit

With ActiveDocument.PageSetup

.LineNumbering.Active = False

.Orientation = wdOrientPortrait

.TopMargin = CentimetersToPoints(3)

.BottomMargin = CentimetersToPoints(2)

.LeftMargin = CentimetersToPoints(3)

.RightMargin = CentimetersToPoints(2)

.Gutter = CentimetersToPoints(0)

.HeaderDistance = CentimetersToPoints(1.25)

.FooterDistance = CentimetersToPoints(1.25)

.PageWidth = CentimetersToPoints(21)

.PageHeight = CentimetersToPoints(29.7)

.FirstPageTray = wdPrinterDefaultBin

.OtherPagesTray = wdPrinterDefaultBin

.SectionStart = wdSectionNewPage

.OddAndEvenPagesHeaderFooter = False

.DifferentFirstPageHeaderFooter = False

.VerticalAlignment = wdAlignVerticalTop

.SuppressEndnotes = False

.MirrorMargins = False

.TwoPagesOnOne = False

.GutterPos = wdGutterPosLeft

End With

ActiveWindow.ActivePane.DisplayRulers = Not ActiveWindow.ActivePane. _

DisplayRulers

With Selection.ParagraphFormat

.LeftIndent = CentimetersToPoints(0)

.RightIndent = CentimetersToPoints(0)

.SpaceBefore = 0

.SpaceBeforeAuto = False

.SpaceAfter = 0

.SpaceAfterAuto = False

.LineSpacingRule = wdLineSpace1pt5

.Alignment = wdAlignParagraphJustify

.WidowControl = True

.KeepWithNext = False

.KeepTogether = False

.PageBreakBefore = False

.NoLineNumber = False

.Hyphenation = True

.FirstLineIndent = CentimetersToPoints(0)

.OutlineLevel = wdOutlineLevelBodyText

.CharacterUnitLeftIndent = 0

.CharacterUnitRightIndent = 0

.CharacterUnitFirstLineIndent = 0

.LineUnitBefore = 0

.LineUnitAfter = 0

End With

MsgBox "Não esqueça de salvar seu documento", vbCritical, "Salvar Documento"

On Error GoTo Tratamento_de_Erros

ActiveDocument.Save

Tratamento_de_Erros:

If Err = 4198 Then

MsgBox "O documento não foi salvo", vbCritical, "Não salvo"

End If

End Sub

Link para o comentário
Compartilhar em outros sites

  • 0
Dae, cara aki está minha macro...

ela configura um documento nos moldes da ABNT, pelo menos parte dele.

O final do código pode ser útil...Lá tem a rotina q usei de tratamento de erro.

qualquer coisa poste outro mensagem

falow!

Sub congig()

'

' congig Macro

' Macro gravada 09/02/05 por Juliano Kazapi

'

CommandBars("Standard").Visible = False

CommandBars("Formatting").Visible = False

ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit

With ActiveDocument.PageSetup

.LineNumbering.Active = False

.Orientation = wdOrientPortrait

.TopMargin = CentimetersToPoints(3)

.BottomMargin = CentimetersToPoints(2)

.LeftMargin = CentimetersToPoints(3)

.RightMargin = CentimetersToPoints(2)

.Gutter = CentimetersToPoints(0)

.HeaderDistance = CentimetersToPoints(1.25)

.FooterDistance = CentimetersToPoints(1.25)

.PageWidth = CentimetersToPoints(21)

.PageHeight = CentimetersToPoints(29.7)

.FirstPageTray = wdPrinterDefaultBin

.OtherPagesTray = wdPrinterDefaultBin

.SectionStart = wdSectionNewPage

.OddAndEvenPagesHeaderFooter = False

.DifferentFirstPageHeaderFooter = False

.VerticalAlignment = wdAlignVerticalTop

.SuppressEndnotes = False

.MirrorMargins = False

.TwoPagesOnOne = False

.GutterPos = wdGutterPosLeft

End With

ActiveWindow.ActivePane.DisplayRulers = Not ActiveWindow.ActivePane. _

DisplayRulers

With Selection.ParagraphFormat

.LeftIndent = CentimetersToPoints(0)

.RightIndent = CentimetersToPoints(0)

.SpaceBefore = 0

.SpaceBeforeAuto = False

.SpaceAfter = 0

.SpaceAfterAuto = False

.LineSpacingRule = wdLineSpace1pt5

.Alignment = wdAlignParagraphJustify

.WidowControl = True

.KeepWithNext = False

.KeepTogether = False

.PageBreakBefore = False

.NoLineNumber = False

.Hyphenation = True

.FirstLineIndent = CentimetersToPoints(0)

.OutlineLevel = wdOutlineLevelBodyText

.CharacterUnitLeftIndent = 0

.CharacterUnitRightIndent = 0

.CharacterUnitFirstLineIndent = 0

.LineUnitBefore = 0

.LineUnitAfter = 0

End With

MsgBox "Não esqueça de salvar seu documento", vbCritical, "Salvar Documento"

On Error GoTo Tratamento_de_Erros

ActiveDocument.Save

Tratamento_de_Erros:

If Err = 4198 Then

MsgBox "O documento não foi salvo", vbCritical, "Não salvo"

End If

End Sub

Olá

coloque isso que já ira resolver o seu caso:

O error resume next

Até mais...

Link para o comentário
Compartilhar em outros sites

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.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...