Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
#10498
olá, com muitas pesquisas consegui criar uma planilha que tem um formulário que gera um arquivo pdf com o nome de acordo com o valor de uma celula e outras coisinhas, um dos problemas é que na hora de gerar o arquivo, se o arquivo ja existe com esse nome ele é substituido, gostaria que fosse possivel adicionar uma numeração tipo (2).pdf se o arquivo existir.
Código: Selecionar todos
Sub salvar()
'
' salvar Macro
'
Dim nome As String
nome = "C:\Users\Jean\Desktop\exames pdf\" & Range("E5") & " - " & Range("k7") & ".pdf"
'
    Sheets("Exame").Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=nome, Quality:=xlQualityStandard _
        , IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        True
    Sheets("PREENCHER").Select
    Range("E5:G5").Select
End Sub
o outro problema é que eu consegui fazer a maioria das coisas gravando macros, e como o formulário está em uma aba, e o modelo a ser preenchido está em outra, quando roda o macro a tela fica piscando porque para o codigo funcionar precisa ficar alternando entre as abas, gostaria de saber se é possível rodar a macro na aba 2 sem precisar de sair da aba onde está o formulário. 
Código: Selecionar todos
Sub ocultar()
'
' ocultar Macro
'

'
    Sheets("Exame").Select
    Range("A34:O42").Select
    Selection.EntireRow.Hidden = True
    Sheets("PREENCHER").Select
    Range("C25:C31").Select
    With Selection.Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -4.99893185216834E-02
    End With
    Range("F25,F27,F29,F31").Select
    Range("F31").Activate
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -4.99893185216834E-02
        .PatternTintAndShade = 0
    End With
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    Selection.Borders(xlEdgeLeft).LineStyle = xlNone
    Selection.Borders(xlEdgeTop).LineStyle = xlNone
    Selection.Borders(xlEdgeBottom).LineStyle = xlNone
    Selection.Borders(xlEdgeRight).LineStyle = xlNone
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    ActiveSheet.Shapes.Range(Array("Rounded Rectangle 1")).Select
    Selection.ShapeRange.ZOrder msoBringToFront
    Range("E5:G5").Select
End Sub
fiquem À vontade para sugerir qualquer mudança, com muito esforço a planilha está ficando com um resultado bem legal. 
vou deixala em anexo. obrigado.
https://drive.google.com/file/d/0BynkAc ... sp=sharing
Preencher Hemograma.xlsm
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord