Skip to main content

AccessTr.neT


Köprü Makro Halinde Yazmak

Köprü Makro Halinde Yazmak

#1
Değerli arkadaşlar;

Kasko_Trafik Excel çalışmasında B (Kasko pdf sini) ve C (Trafik sigortasın pdf) sütunları bastığımızda pdf. getiren bir makro ihtiyacım var. Köprü yapabiliyorum ancak flash bellek ile başka bir bilgisayara taşıdığımda yolu görmediğinden pdf açılmıyor. Bu konuda yardımcı olursanız sevinirim.
.rar Kasko_Trafik.rar (Dosya Boyutu: 355,9 KB | İndirme Sayısı: 5)
Cevapla
#2
Merhabalar,

Klasör içerisendeki dosyalara link işlemini aşağıdaki kod ile yapabilirsiniz.

Kod:
Sub Link_Ekle()
    Dim lastRow As Long
    Dim fileName As String
    Dim folderPath1 As String
    Dim folderPath2 As String
    Dim ws As Worksheet
    Dim i As Long
    Dim workbookPath As String

    Set ws = ThisWorkbook.Sheets(1)
    
    workbookPath = ThisWorkbook.Path
    
    folderPath1 = workbookPath & "\Kasko\"
    folderPath2 = workbookPath & "\Trafik\"
    
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    
    For i = 2 To lastRow
        fileName = ws.Cells(i, 1).Value
        
        If Dir(folderPath1 & fileName & ".pdf") <> "" Then
            ws.Hyperlinks.Add Anchor:=ws.Cells(i, 2), Address:=folderPath1 & fileName & ".pdf", TextToDisplay:="Kasko PDF"
        Else
            ws.Cells(i, 2).Value = "Dosya yok"
        End If
        
        If Dir(folderPath2 & fileName & ".pdf") <> "" Then
            ws.Hyperlinks.Add Anchor:=ws.Cells(i, 3), Address:=folderPath2 & fileName & ".pdf", TextToDisplay:="Trafik PDF"
        Else
            ws.Cells(i, 3).Value = "Dosya yok"
        End If
    Next i
End Sub

Cevapla
#3
(Dün, 12:12)boolean_ yazdı: Merhabalar,

Klasör içerisendeki dosyalara link işlemini aşağıdaki kod ile yapabilirsiniz.

Kod:
Sub Link_Ekle()
    Dim lastRow As Long
    Dim fileName As String
    Dim folderPath1 As String
    Dim folderPath2 As String
    Dim ws As Worksheet
    Dim i As Long
    Dim workbookPath As String

    Set ws = ThisWorkbook.Sheets(1)
   
    workbookPath = ThisWorkbook.Path
   
    folderPath1 = workbookPath & "\Kasko\"
    folderPath2 = workbookPath & "\Trafik\"
   
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
   
    For i = 2 To lastRow
        fileName = ws.Cells(i, 1).Value
       
        If Dir(folderPath1 & fileName & ".pdf") <> "" Then
            ws.Hyperlinks.Add Anchor:=ws.Cells(i, 2), Address:=folderPath1 & fileName & ".pdf", TextToDisplay:="Kasko PDF"
        Else
            ws.Cells(i, 2).Value = "Dosya yok"
        End If
       
        If Dir(folderPath2 & fileName & ".pdf") <> "" Then
            ws.Hyperlinks.Add Anchor:=ws.Cells(i, 3), Address:=folderPath2 & fileName & ".pdf", TextToDisplay:="Trafik PDF"
        Else
            ws.Cells(i, 3).Value = "Dosya yok"
        End If
    Next i
End Sub


Ellerinze sağlık, ancak link işlemini köprü yaparak mı oluşturacağım...
.rar Desktop.rar (Dosya Boyutu: 260,2 KB | İndirme Sayısı: 1)
Cevapla
#4
link işlemini yapmanıza gerek yok dosya adlarını yazdıktan sonra kodu çalıştırın linkler otomatik oluşacak.
Cevapla
#5
(Dün, 14:43)boolean_ yazdı: link işlemini yapmanıza gerek yok dosya adlarını yazdıktan sonra kodu çalıştırın linkler otomatik oluşacak.

Merhabalar;

Değinizi yaptım, çalışıyor. Ellerinize sağlık. Ancak;

lastRow = ws.Cells(ws.Rows.Count, "F").End(xlUp).Row


Benim plakalar F sütunda ve "Kasko" ve "Trafik" boş olan sütunlar G ve H yer almakta böyle çalıştırdığımda veriler gelmiyor ancak ben plakalara A sutüna taşıdığımda B ve C sutünları aktif oluyor. Ne yapmam gerekir.
Cevapla
#6
Merhabalar,

ilgili düzenlemeyi yaptım. Koddan değişen yerleri görebilirsiniz.
Kod:
Sub Link_Ekle()
    Dim lastRow As Long
    Dim fileName As String
    Dim folderPath1 As String
    Dim folderPath2 As String
    Dim ws As Worksheet
    Dim i As Long
    Dim workbookPath As String

    Set ws = ThisWorkbook.Sheets(1)
    
    workbookPath = ThisWorkbook.Path
    
    folderPath1 = workbookPath & "\Kasko\"
    folderPath2 = workbookPath & "\Trafik\"
    
    lastRow = ws.Cells(ws.Rows.Count, "F").End(xlUp).Row
    
    For i = 2 To lastRow
        fileName = ws.Cells(i, 6).Value
        
        If Dir(folderPath1 & fileName & ".pdf") <> "" Then
            ws.Hyperlinks.Add Anchor:=ws.Cells(i, 7), Address:=folderPath1 & fileName & ".pdf", TextToDisplay:="Kasko PDF"
        Else
            ws.Cells(i, 7).Value = "Dosya yok"
        End If
        
        If Dir(folderPath2 & fileName & ".pdf") <> "" Then
            ws.Hyperlinks.Add Anchor:=ws.Cells(i, 8), Address:=folderPath2 & fileName & ".pdf", TextToDisplay:="Trafik PDF"
        Else
            ws.Cells(i, 8).Value = "Dosya yok"
        End If
    Next i
End Sub

Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da
Task