2012-11-02 2 views
0

300 개가 넘는 레코드가있는 Excel 문서가 있습니다.텍스트를 해당 이미지로 바꾸는 방법

각 레코드의 첫 번째 행에는 User Image 변수가 있습니다. 이 레코드는 항상 username.jpg이거나 비어 있습니다.

나는 똑같은 방식으로 이름이 붙여진 이미지가있는 폴더가 있습니다.

첫 번째 행의 텍스트를 관련 이미지로 자동으로 바꿀 수있는 방법이 있습니까?

+0

if (조건) column.row.loadimage()처럼 쉬워야합니다. Visual Basic을 사용하여 몇 가지 연구를 수행해보십시오. 내가 VB를 말하지 않기 때문에 나는 너에게 훨씬 더 큰 도움을 줄 수 없다. – user1534664

+0

이 링크는 꽤 가까운 것 같아요. http://stackoverflow.com/questions/7382739/embed-image-to-excel-spreadsheet-vba –

+0

xD 45 분 안에 완료해야 ... 임씨 C# 사람 .. 또한 Excel에서이 작업을 수행 할 방법을 찾고 있습니다. XML에서 엑셀 시트를 생성하고 있습니다. – TheGeekZn

답변

0

사용자 이미지 변수가 A 열에 있으면이 코드는 A 열에 그림을 삽입하고 그림의 높이로 행의 높이를 조정합니다. 아마도 코드를 약간 조정해야 할 것입니다.

Sub insertPic() 

Dim pic As String 
Dim url As String 
Dim r As Integer 
Dim he As Integer 



url = "C:\User\Pictures\" ' This is the variable to the folder 

For r = 1 To 300 
pic = Sheets("Sheet1").Range("A" & r).Value ' This is your username file 
pic = url & pic 



With ActiveSheet.Pictures.Insert(pic) ' Insert picture into active sheet 
    .Left = ActiveSheet.Range("A" & r).Left ' left and top align the left and top of the picture with the specified cell 
    .Top = ActiveSheet.Range("A" & r).Top 
    he = .Height ' get height of image 


End With 
Sheets("Sheet1").Range("A" & r).Select 
    Selection.RowHeight = he ' match row height to picture height 
Next r 


End Sub 
관련 문제