Kod yardımı

Katılım
17 Şubat 2014
Mesajlar
52
Excel Vers. ve Dili
excel 2013 türkçe
Altın Üyelik Bitiş Tarihi
17.02.2019
Merhaba arkadaşlar, excel dosyasının kısayol simgesini icon yapmak için elimde bir kod var (Const szIconName As String ="\Resim-2.ico") bu şekilde bir sorun yok, fakat ben kırmızı olan kısmı yani resim adını Textbox1'den almasını istiyorum acaba nasıl değiştirebilirim
bu şekilde yaptım ama olmadı ( Const szIconName As String = "\TextBox1.Text")
 

YUSUF44

Destek Ekibi
Destek Ekibi
Katılım
4 Ocak 2006
Mesajlar
12,084
Excel Vers. ve Dili
İş : Ofis 365 - Türkçe
Ev: Ofis 365 - Türkçe
Const szIconName As String = TextBox1.Text
Şeklinde, olmazsa
Const szIconName As String = "\" & TextBox1.Text
şeklinde dener misiniz?

Kırmızı olan kısmın tamamı textboxtan alınacaksa ilki olur diye düşünüyorum.
 
Katılım
17 Şubat 2014
Mesajlar
52
Excel Vers. ve Dili
excel 2013 türkçe
Altın Üyelik Bitiş Tarihi
17.02.2019
YUSUF44 bey, öncelikle ilginizden dolayı teşekkür ederim, her iki şekilde kulandım fakat (.Text) hata veriyor. Sanırım noktadan sonrasını dosya uzantısı olarak algılıyor
 

Emir Hüseyin Çoban

Destek Ekibi
Destek Ekibi
Katılım
11 Ağustos 2008
Mesajlar
5,893
Excel Vers. ve Dili
Office 2013 Tr - Win10 x64
Kullandığınız kodun tamamını görmekte fayda var.

.
 

Emir Hüseyin Çoban

Destek Ekibi
Destek Ekibi
Katılım
11 Ağustos 2008
Mesajlar
5,893
Excel Vers. ve Dili
Office 2013 Tr - Win10 x64
. . .

Yusuf beyin kodlarında textboxa isim girerken isim.ico şeklinde resim uzantısınıda girmeniz gerekiyor veya kodları şu şekilde deneyin.

Kod:
Const szIconName As String = "\" & Textbox1.Text & [COLOR="DarkRed"]".ico"[/COLOR]
. . .
 
Katılım
17 Şubat 2014
Mesajlar
52
Excel Vers. ve Dili
excel 2013 türkçe
Altın Üyelik Bitiş Tarihi
17.02.2019
Hüseyin hocam vermiş olduğunuz kodu kullandım yine hata veriyor. örnek bir dosya hazırladım, zamanınız varsa lütfen bakarmısınız.
 

Ekli dosyalar

Emir Hüseyin Çoban

Destek Ekibi
Destek Ekibi
Katılım
11 Ağustos 2008
Mesajlar
5,893
Excel Vers. ve Dili
Office 2013 Tr - Win10 x64
. . .

Şu şekilde deneyiniz.

Kod:
Private Sub CommandButton1_Click()
     ' Msgbox string variables
    Dim szMsg As String
    Dim szStyle As String
    Dim szTitle As String
      
     ' Change here for the icon's name

    
    'Const szIconName As String = "\Icon\Resim-3.ico"
     ' Constant string values, you can replace "Desktop"
     ' with any Special Folders name to create the shortcut there
    Const szlocation As String = "Desktop"
    Const szLinkExt As String = ".lnk"
     
     
     ' Object variables
    Dim oWsh As Object
    Dim oShortcut As Object
     
     
     ' String variables
    Dim szSep As String
    Dim szBookName As String
    Dim szBookFullName As String
    Dim szPath As String
    Dim szDesktopPath As String
    Dim szShortcut As String
     
     
     ' Initialize variables
    szSep = Application.PathSeparator
    szBookName = szSep & ThisWorkbook.Name
    szBookFullName = ThisWorkbook.FullName
    szPath = ThisWorkbook.Path
     
     
     
    On Error GoTo ErrHandle
     ' The WScript.Shell object provides functions to read system
     ' information and environment variables, work with the registry
     ' and manage shortcuts
    Set oWsh = CreateObject("WScript.Shell")
    szDesktopPath = oWsh.SpecialFolders(szlocation)
     
     
     ' Get the path where the shortcut will be located
    szShortcut = szDesktopPath & szBookName & szLinkExt
     
     
     ' Make it happen
    Set oShortcut = oWsh.CreateShortCut(szShortcut)
     
     
     ' Link it to this file
    With oShortcut
        .TargetPath = szBookFullName
      [COLOR="DarkRed"]  .IconLocation = ThisWorkbook.Path & "\Icon\" & TextBox1.Text [/COLOR]
        .Save
    End With
     
     
     ' Explicitly clear memory
    Set oWsh = Nothing
    Set oShortcut = Nothing
     
     
     ' Let the user know it was created ok
    szMsg = "Masaüstü Kısayolu Oluşturuldu"
    szStyle = 0
    szTitle = "Success!"
    MsgBox szMsg, szStyle, szTitle
     
     
    Exit Sub
     
     
     ' or if it wasn't
ErrHandle:
    szMsg = "Shortcut could not be created"
    szStyle = 48
    szTitle = "Error!"
     
    MsgBox szMsg, szStyle, szTitle

End Sub
. . .
 
Katılım
17 Şubat 2014
Mesajlar
52
Excel Vers. ve Dili
excel 2013 türkçe
Altın Üyelik Bitiş Tarihi
17.02.2019
Hüseyin bey, teşekkür ederim istediğim şekilde oldu.
 
Üst