Tecnologia, programação e muito Visual FoxPro.

sexta-feira, 17 de junho de 2011

Re: ]] XL-mania [[ report VB 6.0 dengan Microsoft Excel

 

Dear rama,

Berikut cuplikan coding vb.6.0 export vb2xls sederhana. Menggunakan
module, datagrid. Coding dibuat pada satu form. Koneksi dibuat pada
module.

============================================================
Option Explicit
Dim MsExcel As Excel.Application
Dim MsWorkbook As Excel.Workbook
Dim a, x, y As Integer
Dim strTarget As String

Sub rowfirst()
RstLook.MoveFirst
a = 6 'dimulai dari row ke 6
x = Val(RstLook.RecordCount) + 5 'dimulai dari row ke 6
End Sub

Private Sub cmdexport_Click()
On Error GoTo errorhandler
With RstLook
If .State = adStateOpen Then .Close
.CursorLocation = adUseClient
.Open "SELECT * FROM tblCustomers", Conn, adOpenKeyset, adLockOptimistic
If .RecordCount > 0 Then
Set MsExcel = New Excel.Application
MsExcel.Workbooks.Open App.Path & "\Data Supplier.xls"
MsExcel.Range("A3").Value = "LAST UPDATE TGL " & Format(Now,
"dd-mm-yyyy")

y = 1
rowfirst
Do While a <= x
If Not .EOF Then
MsExcel.Range("A" & a).Value = y
.MoveNext
a = a + 1
y = y + 1
End If
Loop

rowfirst
Do While a <= x
If Not .EOF Then
MsExcel.Range("B" & a).Value = .Fields(1)
.MoveNext
a = a + 1
y = y + 1
End If
Loop

rowfirst
Do While a <= x
If Not .EOF Then
MsExcel.Range("C" & a).Value = .Fields(2)
.MoveNext
a = a + 1
y = y + 1
End If
Loop

rowfirst
Do While a <= x
If Not .EOF Then
MsExcel.Range("D" & a).Value = .Fields(3)
.MoveNext
a = a + 1
y = y + 1
End If
Loop

strTarget = App.Path & "\Data Export Supplier " & Format(Now,
"yyyymmdd") & ".xls"
If Dir(strTarget) <> "" Then
Kill strTarget
MsExcel.ActiveWorkbook.SaveAs FileName:=strTarget,
FileFormat:=xlNormal
Else
MsExcel.ActiveWorkbook.SaveAs FileName:=strTarget,
FileFormat:=xlNormal
End If
MsgBox "Export Selesai", vbInformation, "Success.."
MsExcel.Visible = True

End If
End With

Exit Sub
errorhandler:
MsgBox Err.Description
End Sub

Private Sub Form_Load()
Call Actcon
With RstSupplier
If .State = adStateOpen Then .Close
.CursorLocation = adUseClient
.Open "SELECT * FROM tblCustomers", Conn, adOpenStatic, adLockOptimistic
If .RecordCount > 0 Then
Set dgSupplier.DataSource = RstSupplier
txtjlh.Text = .RecordCount
End If
End With
End Sub
=================================================================

Saya juga bukan master. Mungkin master2 lain mau turun gunung? Semoga membantu.

Blessings,

Fran'z

On 6/17/11, Rama <rama@gudangmas.com> wrote:
> Dear para master Xl ….
>
>
>
> Saya rama,
>
> Ada yg punya contoh program sederhana vb6.0 yg reportnya pakai excel ??
>
> Saya mau buat program Invoice yg reportnya langsung pakai excel …
>
>
>
> Mohon bantuannya ya para master ☺☺☺
>
>
>
>
>
> B' Regard's
>
>

__._,_.___
Recent Activity:
+-:: XL-mania ::::::::::::::::::::----------------------------------+
| maaf baru moderate sekarang... momods kurang tidur berhari-hari   |
| jadi budak kantoooOOooorrr...                                     |
| http://www.facebook.com/group.php?gid=37671048001&ref=mf          |
+-------------------------------------------------------------------+
| DILARANG : MLM, money game, OOT, iklan tanpa izin, SARA, testing, |
| pembicaraan pribadi, one line message,  melecehkan,  tidak sopan. |
+-------------------------------------------------------------------+
| Buat subjek yang kreatif, jangan : "tanya", "help", "mohon bantu" |
| Usahakan besar attachment < 200 kb. Gunakan  winzip  jika  perlu. |
+-------------------------------------------------------------------+
| Ajak teman-teman Anda bergabung dengan mengirim e-mail kosong ke  |
| XL-mania-subscribe@yahoogroups.com atau kirimkan mereka file dari |
| http://groups.yahoo.com/group/XL-mania/files/Promotion/           |
+-------------------------------------------------------------------+
| Berikan testimoni di : http://www.friendster.com/xlmania atau...  |
| http://www.xl-mania.com/2008/06/testimoni-xl-mania.html           |
+-------------------------------------------------------------------+
| Message lama ada di :                                             |
| http://groups.yahoo.com/group/XL-mania/messages [perlu yahoo id]  |
| http://www.mail-archive.com/xl-mania@yahoogroups.com              |
+-------------------------------------------------------------------+
.

__,_._,___

Nenhum comentário:

Arquivo do blog