Tópico anterior Próximo tópico Novo tópico
VB / VBA
#499790 - 05/05/2022 19:47:46 | ||||
![]() AMELINHACODE SAO PAULO Cadast. em:Junho/2019 ![]() |
Boa noite pessoal,
Preciso criar um 'atalho' para uma pasta meu sistema e colocar na área de trabalho do usuário atual do windows A ideia seria no path do meu sistema, se nao houver a pasta 'ExportarXML' ele cria.... apos isso ele deve criar um atalho dessa pasta na area de trabalho do usuario atual do windows. A parte de verificar se o diretorio existe e se nao existir, deu certo: If Vazio(DiretorioDestino) Then DiretorioDestino = App.path & '\ExportarXML' If Not Existe(DiretorioDestino) Then MkDir DiretorioDestino End If verifica a existência da pasta 'Verifica se arquivo existe
'-1 = Arquivo existe ' 0 = Arquivo não existe ' 2 = Erro! Não existe, diretório inválido ou compartilhado ou Drive não preparado Public Function Existe(ByVal Arq As String) As Integer On Error Resume Next If Len(Arq) > 0 Then Existe = (Len(Dir$(Arq$, vbArchive Or vbDirectory Or vbHidden Or vbNormal Or vbReadOnly Or vbSystem)) > 0) If Err Then Err.Clear Existe = 2 End If Else Existe = 2 End If End Function |
|||
#499793 - 05/05/2022 23:45:54 | ||||
![]() KERPLUNK RIO GRANDE DO SUL Cadast. em:Junho/2009 ![]() |
Acho que o que você quer é só pegar o caminho da pasta do desktop, é isso?
Se for, você pode usar algo assim: Function GetDesktopFolder() As String Dim WSHShell As Object Dim MyRegKey As String Set WSHShell = CreateObject('WScript.Shell') MyRegKey = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop' GetDesktopFolder = WSHShell.regread(MyRegKey) Set WSHShell = Nothing End Function Pra usar seria assim: If Vazio(DiretorioDestino) Then DiretorioDestino = App.path & '\ExportarXML' If Not Existe(DiretorioDestino) Then MkDir GetDesktopFolder & '\' & 'nome_da_sua_pasta' End If _______________________________________________________________________ Virei Oráculo! The end is nigh, be ready for the nukes! |
|||
#499813 - 10/05/2022 21:03:50 | ||||
![]() AMELINHACODE SAO PAULO Cadast. em:Junho/2019 ![]() |
Citação: : Acho que o que você quer é só pegar o caminho da pasta do desktop, é isso? Se for, você pode usar algo assim: Function GetDesktopFolder() As String Dim WSHShell As Object Dim MyRegKey As String Set WSHShell = CreateObject('WScript.Shell') MyRegKey = 'HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerShell FoldersDesktop' GetDesktopFolder = WSHShell.regread(MyRegKey) Set WSHShell = Nothing End Function Pra usar seria assim: If Vazio(DiretorioDestino) Then DiretorioDestino = App.path & 'ExportarXML' If Not Existe(DiretorioDestino) Then MkDir GetDesktopFolder & '' & 'nome_da_sua_pasta' End If Desculpe a demora, tive que me ausentar uns dias da internet... Acabei de testar: MkDir GetDesktopFolder & '\' & 'nome_da_sua_pasta' Realmente vai criar uma pasta na área de trabalho com o nome que denominei em 'nome_da_sua_pasta' Mais na verdade eu precisava era criar um atalho da pasta criar no meu C:\path\ExportarXML e colocar o atalho dessa pasta no desktop do usuario atual do windows Seria algo assim: If Vazio(DiretorioDestino) Then 'começa vazio DiretorioDestino = App.path & '\ExportarXML' 'preenche com o caminho 'C:\Sistema\ExportarXML' If Not Existe(DiretorioDestino) Then MkDir DiretorioDestino 'se a parta 'C:\Sistema\ExportarXML' não existir ele cria If Not Existe(DiretorioDestino) Then MkDir GetDesktopFolder & '\' & 'XML' 'nessa parte ele cria um atalho da pasta ExportarXML que fica no 'C:\Sistema\ExportarXML' e coloca o atalho no deskto End If |
|||
#499820 - 10/05/2022 22:39:50 | ||||
![]() KERPLUNK RIO GRANDE DO SUL Cadast. em:Junho/2009 ![]() |
É quase a mesma coisa. Agora que você está com o objeto do Shell já instanciado, você pode usar o método CreateShortcut
_______________________________________________________________________ Virei Oráculo! The end is nigh, be ready for the nukes! |
|||
#499821 - 10/05/2022 22:54:49 | ||||
![]() AMELINHACODE SAO PAULO Cadast. em:Junho/2019 ![]() |
Citação: : É quase a mesma coisa. Agora que você está com o objeto do Shell já instanciado, você pode usar o método CreateShortcut Seria assim? If Vazio(DiretorioDestino) Then 'começa vazio
DiretorioDestino = App.path & '\ExportarXML' If Not Existe(DiretorioDestino) Then MkDir DiretorioDestino If Not Existe(DiretorioDestino) Then MkDir CreateShortcut GetDesktopFolder DiretorioDestino End If |
|||
#499823 - 10/05/2022 23:36:32 | ||||
![]() KERPLUNK RIO GRANDE DO SUL Cadast. em:Junho/2009 ![]() |
Não. A instância de shell:
Dim WSHShell As Object Set WSHShell = CreateObject('WScript.Shell') WSHShell.CreateShortcut(Pasta_destino) _______________________________________________________________________ Virei Oráculo! The end is nigh, be ready for the nukes! |
|||
Tópico anterior Próximo tópico Novo tópico