Click to See Complete Forum and Search --> : VB to Excel
parkes
Jan 12th, 2000, 05:11 PM
I'm using VB6 and Excel
I've got an Excel spreadsheet already created and I want to send information to certain cells.
Does anyone have an example on how to do this.
------------------
Thanks in advance for any help provided.
SteFlitII
Jan 12th, 2000, 08:42 PM
I'm stuck on this to cannot find anything on the web....is it possible??
netSurfer
Jan 12th, 2000, 08:52 PM
It is possible. I had the same problem, the help files in VB and Excel didn't help until I looked at both and cross-referenced them and guessed a bit. I'm in the middle of something but when I get a chance I will see if I can my code doing it.
Basically, you need to make an Excel object, use it to open the file and then just do things with the properties etc. It may take me a bit, gotta finish some stuff first.
Quick example doing it in Access's VBA, opening a Word Document.
Dim WordDoc As Object
Set WordDoc = CreateObject("word.application")
WordDoc.Application.Visible = True
WordDoc.Application.Documents.Open strFileName
WordDoc.Application.windowstate = 1
Basically it's the same but using and Excel object and OpenObject or similar. Hope this gets you started in the right direction. Let me know if you need more or if this helped enough.
matthewbyran@hotmail.com
[This message has been edited by netSurfer (edited 01-13-2000).]
parkes
Jan 13th, 2000, 11:17 AM
Thanks people, I've found the answer, so if you want I'll post it for you. Or you can email me and I'll send it
------------------
Thanks in advance for any help provided.
netSurfer
Jan 13th, 2000, 11:30 AM
Sure, could you post it.
parkes
Jan 13th, 2000, 04:28 PM
Right here is the basic information:
Private tmpWorkbook As Excel.Workbook
Private tmpWorkSheet As Excel.Worksheet
Private Sub cmdExport_Click()
Dim fname As String
fname = "c:\my documents\test.xls"
Set tmpWorkbook = GetObject(fname)
tmpWorkbook.Sheets("Sheet 1").Select
Set tmpWorkSheet = tmpWorkbook.ActiveSheet
With tmpWorkSheet
.Cells(7,3)="Testing"
End With
End Sub
Hope this helps.
------------------
Thanks in advance for any help provided.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.