Reg : GUI

  • Thread starter Thread starter naresh_kalyan
  • Start date Start date
N

naresh_kalyan

Dear all,
Presently I am learning VB. I prepared a GUI for Excel.
My basic intension is ...
As we entered values in GUI, it should open MSExcel file(which is
already there in my local drive), print all these values in the
corresponding fields and then save the file.
Can you please give me an example, How to link the values to the Excel
file.

Thanks in advance.

Regards
Kalyan
 
Try something like the following:

Dim WB As Excel.Workbook
Set WB = XLApp.Workbooks.Open(Filename:="H:\Book1.xls")' CHANGE
FILE NAME
WB.Worksheets("Sheet1").Range("A1").Value = Me.textbox1.Text
' more code
WB.Close savechanges:=True

where XLApp is your reference to the Excel application. The code
above will place the contents of a textbox named textbox1 in cell
A1 of Sheet1.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"naresh_kalyan"
<[email protected]>
wrote in message
news:[email protected]...
 
Dear Pearson,
Thank you for your quite immediate response.
But, I am not that aware about VB and hence I could not able t
understand your valuable code.
Is it convenient for you to send it more descriptively, if possible.
Please.

Thank you,
Kalya
 
In your original post, you stated that you were using "VB". I
assumed that this meant VB6 or VB.NET, not VBA.

By GUI, I assume you mean "graphical user interface"; in other
words, as UserForm. If you are working with VBA in Excel, and
your GUI is a UserForm, you can use code like


Dim WB As Excel.Workbook
Set WB = Workbooks.Open(Filename:="H:\Book1.xls")' CHANGE
FILE NAME
WB.Worksheets("Sheet1").Range("A1").Value =
Userform1.TextBox1.Text
' more code
WB.Close savechanges:=True

The code above declares a variable named WB of the type Workbook.
The command

Set WB = Workbooks.Open(Filename:="H:\Book1.xls")

opens the workbook named "H:\Book1.xls" as sets the WB variable
to that workbook. The line of code

WB.Worksheets("Sheet1").Range("A1").Value =
Userform1.TextBox1.Text

places the text from a textbox control named TextBox1 into cell
A1 on Sheet1 in the WB workbook. The line of code
WB.Close savechanges:=True

closes the WB workbook and saves the changes.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com










"naresh_kalyan"
<[email protected]>
wrote in message
news:[email protected]...
 
Dear Pearson,
Thanks for your patiance and time.
I am writing code in Visual Basic 2005 Express Edition. It is NOT th
VBA which is a built-in application with MSExcel. I already made
Graphical User Interface in this. And now I have to control my Exce
file which is in the local drive.

What exactly I thought is,

1. I developed a GUI.
2. User will enter values in the textboxes.
3. All textboxs information should be printed in Excel file, which i
my End result.

I hope a great response from you.

Thank you,
Regards
Kalya
 
Dear Tom,
I gone thru the sites which u had given.
As I am in the initial stage, please could you send one example whic
transfer some data from Visual Basic 6.0 to Microsoft Excel.

Hope you will do the needful.

Thank you,
Kalya
 
Dear Tom,
Greatly, I had created one Excel Document thru VB.
Thank you so much.
But, I need to link my data with an *Existing* Document.
Thanks in advance.

Regards
Kalyan
 
Dear Tom,
Please can you help me how to open an existing file and saving it with
different name. I would like to open Book1 and passing the data and
finally I want to save it as "BOM".

Thanks in advance.

Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

oExcel = CreateObject("Excel.Application")
oBook = oExcel.("c:\book1").Add


'Add data to cells of the first worksheet in the new workbook
oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = "S.No."
oSheet.Range("B1").Value = "Description"
' oSheet.Range("A1:B1").Font.Bold = True
oSheet.Range("A2").Value = "1"
oSheet.Range("B2").Value = "Nothing"


'Save the Workbook and Quit Excel
oBook.SaveAs("C:\BOM.xls")
oExcel.Quit()
 
Dear all,
After passing the data, "form1" should again prompt me unless until
press cancel. the code should REPEAT the same "form1" unless until
cancel the window. After passing values to cell "A2 & B2", it shoul
pass to "A3 & B3" and like wise all parts.
For clear Description, Please find the attachment named "Query.jpg".

Thanks in Advance.

Kalya

+-------------------------------------------------------------------
|Filename: Query.jpg
|Download: http://www.excelforum.com/attachment.php?postid=4940
+-------------------------------------------------------------------
 
Back
Top