is there a way to take data from msflexgrid and put it into a ready made excel file(meaning some boxes in excel is already filled)? And it is put into some specific place in the Excel template.

Data from MSFlexGrid-->Excel Template.

Thank you.

I have put up the coding that i did in this thread.

If you can, please mend or at least tell me what is wrong. Much appreciated.

Thanks for the link. By the way, all of the links that you gave me were to put the data into a new excel when i wanted to put it into an existing excel. Is there a specific line of coding where it will put data directly into the existing excel? I just need that. Thank you for being patient with me.

Yes, there is. Firstly you need to find out if the excell sheet is open or not. Unfortunately in vb6, it only checks for the LAST workbookthat has been opened. If there is more than one workbook open, it will only read the last open. Once you have determined that the workbook is open, activate it and add the data to the sheet -

Dim MaximiseExcel As Excel.Application

On Error Resume Next

Set MaximiseExcel = GetObject(, "Excel.Application" 'Do not forget the comma ',' after the first bracket!!)

'All code to add to workbook here.
'ExcelOpen.ActiveWindow.Caption can be used to determine that you will be adding the data to the correct workbook as well.

MaximiseExcel.WindowState = xlMaximized 'Only use this to show the workbook once all the data has been added.

The "GetObject" can be used for ALL MS office applications.

I hope this helps.

can you tell me what's wrong with this code? It kept saying "User defined type not defined"

Public objExcel As Excel.Application

You need to go to 'References' and select Microsoft Excel object library 11 (or whatever version you have). This will then define the object in code.

This question has already been answered. Start a new discussion instead.