RE: Need help to create a macro or vba script to export data from exce



Hi,

I think you may try to use the code below to dump the cell one by one, so
that we can accurately control the output.
Here is a sample for your reference.
Sub Test()
Dim fso As New FileSystemObject
Dim ts As TextStream
Set ts = fso.CreateTextFile("c:\temp\output.txt", True, True)
Dim col As Integer
col = 4
Dim row As Integer
row = 8
Dim i As Integer
Dim j As Integer
For i = 1 To row
For j = 1 To col
If j = col Then
ts.Write CStr(Cells(i, j))
Else
ts.Write CStr(Cells(i, j)) & ","
End If
Next
ts.Write (vbCrLf)
Next
ts.Close
End Sub

Also for your second question about sending mail from the macro, we can
automation Outlook to do that.

Here is KB for your reference.
161088 Using Automation to Send a Microsoft Outlook Message
http://support.microsoft.com/default.aspx?scid=kb;EN-US;161088

If you still have any concern, please post back and I am glad to be of
assistance.


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

.



Relevant Pages

  • Re: DirectoryService and get all groups
    ... Dim dirEnt As New DirectoryEntry ... Dim srGroupsCol As SearchResultCollection = dsGroups.FindAll ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: DirectoryService and get all groups
    ... Dim dirEnt As New DirectoryEntry ... Dim srGroupsCol As SearchResultCollection = dsGroups.FindAll ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: Problem when showing MdiChild form
    ... logic order wrong in showing the MDI child form. ... Dim childFormsAs Windows.Forms.Form ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.vb)
  • RE: How to dump system service dispatch table?
    ... Yes, to dump SSDT programmatically, we may get the KeServiceDescriptorTable ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.win32.programmer.kernel)
  • RE: Need help to create a macro or vba script to export data from
    ... I think you may try to use the code below to dump the cell one by one, ... Dim fso As New FileSystemObject ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.office.developer.vba)

Loading