• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Dosyanın yer aldığı klasörün adını MsgBox'da göster

  • Konbuyu başlatan Konbuyu başlatan meslek5
  • Başlangıç tarihi Başlangıç tarihi
Katılım
19 Eylül 2012
Mesajlar
322
Excel Vers. ve Dili
2010 türkçe
Merhaba açık Excel dosyasının içinde yer aldığı klasör adını MsgBox'da gösterebilir miyiz?
Örneğin; Masa üstünde (herhangi bir konumda da olabilir) Kitap1.xlsm adlı bir dosyayı açtım ve bir butona basarak bu Excel dosyasının hangi klasör içinde yer aldığını mesaj kutusunda görmek istiyorum.

Ayrıca başka bir butona bastığımda açık Excel dosyamın yer aldığı klasör içindeki DENEME adlı klasörü açmak istiyorum bunlar mümkün müdür?

Biraz karışık bir soru oldu umarım anlatabilmişimdir. Şimdiden teşekkür ederim.
 
Merhaba,

Açık dosya yolu için aşağıdaki kodu kullanabilirsiniz.

C++:
Option Explicit

Sub ActiveWorkbook_Path()
    MsgBox ThisWorkbook.Path
End Sub
 
Merhaba,

Açık dosya yolu için aşağıdaki kodu kullanabilirsiniz.

C++:
Option Explicit

Sub ActiveWorkbook_Path()
    MsgBox ThisWorkbook.Path
End Sub

Korhan bey teşekkür ederim. Sadece klasör adını gösterebilir miyiz? mesela açık excel DENEME adlı klasör içindeyse mesaj kutusunda DENEME yazsın.
 
Kod:
    MsgBox StrReverse(Split(StrReverse(ThisWorkbook.Path), Application.PathSeparator)(0))

.
 
Farklı alternatifler...

C++:
Option Explicit

Sub ActiveWorkbook_Path()
    MsgBox Mid(ThisWorkbook.Path, InStrRev(ThisWorkbook.Path, Chr(47)) + 1, 255)
    MsgBox Replace(Mid(ThisWorkbook.Path, InStrRev(ThisWorkbook.Path, Chr(47)), 255), Chr(47), "")
    MsgBox Trim(Right(Replace(ThisWorkbook.Path, Chr(47), Space(999)), 999))
    MsgBox Split(ThisWorkbook.Path, Chr(47))(UBound(Split(ThisWorkbook.Path, Chr(47))))
    MsgBox StrReverse(Split(StrReverse(ThisWorkbook.Path), Chr(47))(0))
    MsgBox StrReverse(Left(StrReverse(ThisWorkbook.Path), InStr(1, StrReverse(ThisWorkbook.Path), Chr(47)) - 1))
End Sub
 
Farklı alternatifler...

C++:
Option Explicit

Sub ActiveWorkbook_Path()
    MsgBox Mid(ThisWorkbook.Path, InStrRev(ThisWorkbook.Path, Chr(47)) + 1, 255)
    MsgBox Replace(Mid(ThisWorkbook.Path, InStrRev(ThisWorkbook.Path, Chr(47)), 255), Chr(47), "")
    MsgBox Trim(Right(Replace(ThisWorkbook.Path, Chr(47), Space(999)), 999))
    MsgBox Split(ThisWorkbook.Path, Chr(47))(UBound(Split(ThisWorkbook.Path, Chr(47))))
    MsgBox StrReverse(Split(StrReverse(ThisWorkbook.Path), Chr(47))(0))
    MsgBox StrReverse(Left(StrReverse(ThisWorkbook.Path), InStr(1, StrReverse(ThisWorkbook.Path), Chr(47)) - 1))
End Sub

Korhan hocam size de çok teşekkür ederim. İyi ki varsınız
 
Kod:
    MsgBox StrReverse(Split(StrReverse(ThisWorkbook.Path), Application.PathSeparator)(0))

.

Korhan hocam hani açık excelin bulunduğu klasör adını yukardaki kod ile mesaj kutusunda gösterebiliyoruz ya peki söz konusu klasörün içinde yer alan HESAPLAR adlı klasörü mesaj kutuna tamam dediğimizde açabilir miyiz?
 
Deneyiniz.

C++:
Option Explicit

Sub Show_Folder()
    Shell "Explorer " & ThisWorkbook.Path & "\HESAPLAR", vbNormalFocus
End Sub
 
Kod:
    Shell "explorer " & ThisWorkbook.Path & "\HESAPLAR", vbNormalFocus


.
 
Geri
Üst