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

Tudo que estiver relacionado ao Excel básico, como somar, calcular média, colocar bordas, etc.
  • Avatar do usuário
Por fernandoreus
Posts
#53243
Estou precisando de um código VBA, e não consegui encontrar no fórum e nem na internet, que seria exportar a planilha 8 do arquivo que estou enviando como exemplo, e alem de exportar para .pdf, quero que nomeie o arquivo novo, como "Arquivo-" e depois "CélulaA1[que é o nome da pessoa" e depois "data".

Ficando como Exemplo: Arquivo - Fernando26032020.pdf

Tenho o Office 2019, e rodo ele no Mac
Você não está autorizado a ver ou baixar esse anexo.
Avatar do usuário
Por JCabral
Avatar
#53249
Tente adaptar esse código ao seu caso:
Código: Selecionar todos
Sub PDFActiveSheetNoPrompt()
'www.contextures.com
'for Excel 2010 and later
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler

Set wbA = ActiveWorkbook
Set wsA = ActiveSheet

'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
  strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"

strName = wsA.Range("A1").Value _
          & " - " & wsA.Range("A2").Value _
          & " - " & wsA.Range("A3").Value

'create default name for savng file
strFile = strName & ".pdf"
strPathFile = strPath & strFile

'export to PDF in current folder
    wsA.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=strPathFile, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
    'confirmation message with file info
    MsgBox "PDF file has been created: " _
      & vbCrLf _
      & strPathFile

exitHandler:
    Exit Sub
errHandler:
    MsgBox "Could not create PDF file"
    Resume exitHandler
End Sub
Por fernandoreus
Posts
#53271
Então fiz isso, vou colocar o código, porém quando eu mudo o arquivo .xlsm de pasta, ele não está mais salvando em .pdf ele busca minha impressora, mas não consegui identificar o erro. Conseguiria me ajudar?
Código: Selecionar todos
Sub Imagem2_Clique()
Dim LocalPDF As String
LocalPDF = ThisWorkbook.Path & "/" & "Orçamento - " & Sheets("Dados Cliente").Range("D2").Value & " - " & Replace(Date, "/", "-")
    Sheets("Impressão").ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
        LocalPDF & ".pdf", Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
    Sheets("Dados Cliente").Select
End Sub
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