Retrieving cell formatting from closed workbook
Hey guys, I've studied C++ for a couple of years, but I am somewhat new to
Excel VBA -- so I was wondering if you could help me out. Here's the problem: Currently, I have a GetValue function which pulls a cell's value from a closed workbook and an OutputData function which stores the value in the corresponding cell of the active sheet, however the cell's formatting is lost in the process. Is it possible to carry any of the cell's formatting across and, if so, could someone advise me on how to do this? In particular, what objects, classes, or functions might I need? Also, would a GetFormat function call from GetValue slow the processing speed down much more than just passing more parameters to the GetValue function? Thanks. Private Function GetValue(path, file, sheet, ref) Dim arg As String arg = "'" & path & "[" & file & "]" & sheet & "'!" & Range(ref).Range("A1").address(, , xlR1C1) GetValue = ExecuteExcel4Macro(arg) End Function Private Function OutputData(File, InputRow, OutputRow, FileDone) p = PathName(File) f = FileName(File) s = "InputSheet" Do For c = 1 To 20 a = Cells(InputRow, c).address Activesheet.Cells(OutputRow, c) = GetValue(p, f, s, a) Next c InputRow = InputRow + 1 If Not FileDone Then OutputRow = OutputRow + 1 Exit Do FileDone = True Loop End Function |
All times are GMT +1. The time now is 05:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com