Jump to content
Fórum Script Brasil
  • 0

Copiar o arquivo para pen drive com várias cópias


degui
 Share

Question

Encontrei essa função na internet, para renomear arquivos com VBA... testei no meu Excel e funcionou tranquilo, mas preciso fazer umas alterações.

 

Preciso criar várias cópia de um arquivo em um pendrive...

 

Por exemplo

 

o arquivo c:\temp\logo.jpg

 

copiar 3 vezes para o pendrive, com os nomes

 

logo1.jpg

logo2.jpg

logo3.jpg

 

 

fiz um for, executando a cada laço a função VbCopyFolder, e até funcionou, o problema é que para cada laço ele abre uma barra de progresso da cópia...

 

quero que para todos os arquivos sejam abertas apenas uma barra de progresso da cópia... só sendo fechada quando todos os arquivos forem copiados

Public Declare Function SHFileOperation Lib "shell32.dll" _
Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Public Const FO_COPY = &H2


Public Type SHFILEOPSTRUCT
    hWnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAnyOperationsAborted As Long
    hNameMappings As Long
    lpszProgressTitle As Long
End Type

Public Sub VBCopyFolder(ByRef strSource As String, ByRef strTarget As String)
    Dim op As SHFILEOPSTRUCT

    With op
        .wFunc = FO_COPY
        .pTo = strTarget
        .pFrom = strSource
        .fFlags = FOF_SIMPLEPROGRESS
    End With

    SHFileOperation op
End Sub

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.2k
×
×
  • Create New...