ERRO NA GERAÇÃO DE ...
 
Notifications
Clear all

ERRO NA GERAÇÃO DE PASTA NOS DRIVES DO COMPUTADOR

6 Posts
2 Usuários
0 Reactions
1,230 Visualizações
(@setti)
Posts: 150
Estimable Member
Topic starter
 

Boa noite, gostaria de uma ajuda com um código. O meu computador não reconhece os drives para criar as pastas para gerar arquivos pdf. Precisa instalar alguma referência??

obrigado,

Rafael

If TEXTPRofissional2 <> "" Then
VOLTAR:
Else
Dim linha, pasta5

 Dim FileName As String, Path As String, meuArqu

        Path = "C:RELATORIO_CLINICAVENDASSERVICO"
       
       'VERIFICA SE O CAMINHO EXISTE
        If Dir("C:RELATORIO_CLINICAVENDASSERVICO", vbDirectory) = Empty Then
Set pasta5 = linha.CreateFolder("C:RELATORIO_CLINICAVENDASSERVICO")
CreateFolderDemo = PASTA3.Path
End If





    If Not isfileopen("C:RELATORIO_CLINICAVENDASSERVICO" & "RELATORIO-" & Me.TEXTPRofissional2.Text & "-" & TEXTMES2.Text & "-" & TEXTANO2.Text & ".pdf") Then



With ActiveSheet
.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:="C:RELATORIO_CLINICAVENDASSERVICO" & "RELATORIO-" & Me.TEXTPRofissional2.Text & "-" & TEXTMES2.Text & "-" & TEXTANO2.Text & ".pdf", _
openafterpublish:=True
End With

Else
MsgBox ("EXISTE UM ARQUIVO COM MESMO NOME JÁ ABERTO, POR FAVOR FECHE-O PARA PROSSEGUIR E CLIQUE EM OK!!!")
GoTo VOLTAR:
End If
End If

If TEXTPROF <> "" Then
VOLTAR2:
    Dim linha2, PASTA3

Set linha2 = CreateObject("Scripting.FileSystemObject")

If Dir("C:RELATORIO_CLINICAVENDASPROFISSIONAIS", vbDirectory) = Empty Then
Set PASTA3 = linha2.CreateFolder("C:RELATORIO_CLINICAVENDASPROFISSIONAIS")
CreateFolderDemo = PASTA3.Path
End If

    If Not isfileopen("C:RELATORIO_CLINICAVENDASPROFISSIONAIS" & "RELATORIO-" & Me.TEXTPROF.Text & "-" & TextMES.Text & "-" & TextANO.Text & ".pdf") Then



With ActiveSheet
.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:="C:RELATORIO_CLINICAVENDASPROFISSIONAIS" & "RELATORIO-" & Me.TEXTPROF.Text & "-" & TextMES.Text & "-" & TextANO.Text & ".pdf", _
openafterpublish:=True
End With

Else
MsgBox ("EXISTE UM ARQUIVO COM MESMO NOME JÁ ABERTO, POR FAVOR FECHE-O PARA PROSSEGUIR E CLIQUE EM OK!!!")
GoTo VOLTAR2:
End If
End If

CommandButton1.Enabled = False
CommandButton2.Enabled = False
CommandButton3.Enabled = False
End With
End Sub
 
Postado : 15/04/2015 7:47 pm
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Já usou o FileSystemObject para manipular arquivos, pastas e drives ? É bem melhor e mais fácil que o dir...

Agora... coloca aí a linha que dá esse erro , please?

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 15/04/2015 9:26 pm
(@setti)
Posts: 150
Estimable Member
Topic starter
 
Set PASTA5 = linha.CreateFolder("C:RELATORIO_CLINICAVENDASSERVICO")
 
Postado : 16/04/2015 8:14 am
(@setti)
Posts: 150
Estimable Member
Topic starter
 

já tentei o mkdir também e dá o mesmo erro...

 
Postado : 16/04/2015 8:16 am
(@setti)
Posts: 150
Estimable Member
Topic starter
 

Eu consegui resolvendo assim

 dim pasta,pasta2
  Dim fso As New Scripting.FileSystemObject
Pasta = "C:RELATORIOS_HISTORICOS"
            PASTA2 = "CLIENTES"  
    If Not fso.FolderExists(Pasta) Then fso.CreateFolder Pasta
    If Not fso.FolderExists(Pasta & "/" & PASTA2) Then fso.CreateFolder Pasta & "/" & PASTA2

:mrgreen:

 
Postado : 16/04/2015 12:44 pm
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Que bom que minha dica deu certo.

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 16/04/2015 7:53 pm