ferreira12 Posted July 8, 2013 at 10:56 AM Report #517599 Posted July 8, 2013 at 10:56 AM Boas... Nunca trabalhei com o VBa, mas surgiu uma necessidade de elaborar um pequeno trabalho. Eu gostaria de a abrir um open file... mas esse open file abrisse já numa directoria pré definida. pois a pasta em questão está partilhada na rede. Tenho já este código, será que me poderem ajudar a colocar o caminho da directoria? Public Function OpenFileDialog() As String Dim Filter As String, Title As String Dim FilterIndex As Integer Dim Filename As Variant ' Define o filtro de procura dos arquivos Filter = "Picture Files,*.bmp;*.tif;*.jpg;*.png,PNG (*.png),*.png,TIFF (*.tif),*.tif,JPG (*.jpg),*.jpg,All Files (*.*),*.*" ' O filtro padrão é *.* FilterIndex = 1 ' Define o Títuloo (Caption) da Tela Title = "Selecione um arquivo" ' Define o disco de procura ChDrive ("C:") ChDir ("D:") With Application ' Abre a caixa de diálogo para seleção do arquivo com os parâmetros Filename = .GetOpenFilename(Filter, FilterIndex, Title) ' Reseta o Path ChDrive (Left(.DefaultFilePath, 1)) ChDir (.DefaultFilePath) End With ' Abandona ao Cancelar If Filename = False Then MsgBox "Nenhum arquivo foi selecionado." Exit Function End If ' Retorna o caminho do arquivo OpenFileDialog = Filename End Function
nelsonr Posted July 8, 2013 at 02:31 PM Report #517648 Posted July 8, 2013 at 02:31 PM Boas, tens o ChDir a definir um disco, coloca a pasta que queres abrir Isto a mim resolve: ' Define o disco de procura ChDrive ("D:") ChDir ("\GAMES")
ferreira12 Posted July 8, 2013 at 05:37 PM Author Report #517690 Posted July 8, 2013 at 05:37 PM Problema Resolvido. Obrigado
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now