Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 11th, 2003, 07:04 AM
Registered User
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to PHANI KISHOREKOTTAPALLI Send a message via Yahoo to PHANI KISHOREKOTTAPALLI
Default vb with excel

hi can any one help to store data from vb to excel in matrix format.

suppose my gui having matrix format of text boxes the client will

enter his data through gui in text boxes , he want to store those text

box information automatically in excel sheet in same format.

can any one help.

 
Old August 11th, 2003, 07:11 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think you will have to save the data for each text box separately. The fact that they are ordered in a particular way in your GUI doesn't link them into an array in any way.
 
Old August 11th, 2003, 08:49 AM
Authorized User
 
Join Date: Aug 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

PHANI KISHOREKOTTAPALLI,

Can you be more specific about what it is you're trying to learn??

Do you need to:
a) Learn how to start Excel using VB.
b) Place information in a worksheet from VB.
c) Place the information from textboxes into an array?

For more info recommend http://www.vba-programmer.com

CarlR

 
Old August 13th, 2003, 01:31 PM
Authorized User
 
Join Date: Aug 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

PHANI KISHOREKOTTAPALLI,

An approach that I've used and which has worked very well, is to create a tab-delimited text file with a VB program, and then when it's all done, give the User of opening the tab-delimited file in Notepad or Excel.

Here's the code under the 2 command buttons:
(a) For bring Text file into Excel (name of file stored in MyFinalPathFile variable):
' ************************************************** **************
' Import Tab-Delimited Output File into Excel
' ************************************************** **************
Private Sub cmdImportToExcel_Click()
' ************************************************** *****************
Dim ExcelApp As Object
On Error GoTo APPLICATION_CREATE ' An error will cause us to initiate the Appl.
Set ExcelApp = GetObject(, "Excel.Application")
GoTo SKIP_APPLICATION_CREATE ' Of course if it's already there, then we'll use that
APPLICATION_CREATE:
Set ExcelApp = CreateObject("Excel.Application")
SKIP_APPLICATION_CREATE:
On Error GoTo BYE ' Back to our normal way of life
' ************************************************** *******************
Dim myArray()
For i = 1 To intColumns
    ReDim Preserve myArray(i)
    myArray(i) = Array(i, 2)
Next
' ************************************************** *******************
Application.StatusBar = ". . . . . . . . . . . . . . . IMPORTING INTO EXCEL !! . . "
ExcelApp.Workbooks.OpenText FileName:=MyFinalPathFile, _
    Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
    :=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:= _
    False, Comma:=False, Space:=False, Other:=False, FieldInfo:=myArray()
ColumnString = "A:" & ConvertColumnNumberToLetter(intColumns)
ExcelApp.Columns(ColumnString).EntireColumn.AutoFi t
ExcelApp.Range("A1").Select
ExcelApp.Visible = True
Application.StatusBar = ""
BYE:
End Sub

(b) For bringing file into NotePad:
Private Sub cmdViewOutputWithNotepad_Click()
    Shell "Notepad.exe" & " " & MyFinalPathFile, vbMaximizedFocus
End Sub

For more info recommend http://www.vba-programmer.com

CarlR


 
Old May 18th, 2004, 08:03 PM
Authorized User
 
Join Date: Jul 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Tere
Default

I am reading this issue and trying the last code but I received and error because the function ConvertColumnNumberToLetter is not declare on my project. Can you sent it?






Similar Threads
Thread Thread Starter Forum Replies Last Post
VB and Excel ivanlaw Pro VB 6 12 August 6th, 2007 01:20 AM
Excel with VB arijit_bose VB How-To 2 April 21st, 2005 05:43 AM
vb to excel. sonurijs Excel VBA 1 March 14th, 2005 05:43 AM
Excel and VB Marcela Excel VBA 1 May 21st, 2004 01:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.