|
-
Aug 15th, 2005, 02:55 AM
#1
Thread Starter
Fanatic Member
[Resolved]How to get save excel file
I have an excel file with some data already entered into it.
now i want to mention row and column of the sheet and want to save whatever in text box ..
how to do it ..?
Last edited by vbPoet; Aug 15th, 2005 at 07:58 AM.
-
Aug 15th, 2005, 03:13 AM
#2
Thread Starter
Fanatic Member
Re: How to save in Excel file
Like i want to save data in textbox Text1 into c:\anyname.xls Row 25 Column C.......
-
Aug 15th, 2005, 03:46 AM
#3
Re: How to save in Excel file
ActiveSheet.Cells(2, 2).Formula = InputBox("Enter text")
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 03:48 AM
#4
Re: How to save in Excel file
Are you coding this using VBA in Excel, or is it a separate VB executable?
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 03:52 AM
#5
Thread Starter
Fanatic Member
Re: How to save in Excel file
 Originally Posted by trisuglow
Are you coding this using VBA in Excel, or is it a separate VB executable?
It is separate Vb executable ..
but i want some more assistance how to open excel file with already saved some data and how to save it altogether after adding more data...
-
Aug 15th, 2005, 04:04 AM
#6
Re: How to save in Excel file
This should write the entered text into C25 on Sheet1.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim xl As New Excel.Application
xl.Workbooks.Open "C:\anyname.xls"
xl.Worksheets(1).Cells(25, 3).Formula = InputBox("Enter Text")
xl.Save
xl.Quit
End Sub
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 04:04 AM
#7
Re: How to save in Excel file
Forgot to mention - you have to go to Project\References and add a reference to "Microsoft Excel Object Library"
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 04:33 AM
#8
Thread Starter
Fanatic Member
Re: How to save in Excel file
But there is one problem with this code..
it wants to replace original file .
but i just want to add more data ...
what to do ..?
-
Aug 15th, 2005, 04:42 AM
#9
Re: How to save in Excel file
If you want to add more data then you will have to overwrite the exisiting file. Even if you knew which byte(s) in the file you wanted to change and just wrote over them you would still have to open and close the file (effectively overwriting it).
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 04:50 AM
#10
Thread Starter
Fanatic Member
Re: How to save in Excel file
Previous problem is solved ..
but here is new one..
i have some Text data in Text Box when i m saving it to ( 25,1) in excel file only "#VALUE!" is displaying ...
How to solve this last problem ..?
Last edited by vbPoet; Aug 15th, 2005 at 05:03 AM.
-
Aug 15th, 2005, 05:13 AM
#11
Fanatic Member
Re: How to save in Excel file
You could try changing:
xl.Worksheets(1).Cells(25, 3).Formula = InputBox("Enter Text")
to:
xl.Worksheets(1).Cells(25, 3).Value = InputBox("Enter Text")
Do canibals not eat clowns because they taste funny? 
-
Aug 15th, 2005, 05:20 AM
#12
Re: How to save in Excel file
vbPoet, It sounds like the cell type is set up as Numeric rather then General. You can either change the cell type to General, or make sure you only write numeric values into it. From memory, it may also be to do with the value that Excel is trying to display being too wide (ie too many significant digits) to fit in the cell.
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 05:21 AM
#13
Thread Starter
Fanatic Member
Re: How to save in Excel file
 Originally Posted by doofusboy
You could try changing:
xl.Worksheets(1).Cells(25, 3).Formula = InputBox("Enter Text")
to:
xl.Worksheets(1).Cells(25, 3).Value = InputBox("Enter Text")
of no use ...
my exact line of code is
VB Code:
xl.Worksheets(1).Cells(25, 1).Value = Text2
in Text2 there is nearly 700 words long text ...
instead of displaying text
in excel file there is just #VALUE! written.
-
Aug 15th, 2005, 05:27 AM
#14
Thread Starter
Fanatic Member
Re: How to save in Excel file
 Originally Posted by trisuglow
vbPoet, It sounds like the cell type is set up as Numeric rather then General. You can either change the cell type to General, or make sure you only write numeric values into it. From memory, it may also be to do with the value that Excel is trying to display being too wide (ie too many significant digits) to fit in the cell.
Yes this is wide data ...
How to solve this issue ..?
-
Aug 15th, 2005, 05:29 AM
#15
Re: How to save in Excel file
Read the Excel help - there is a section under the "#VALUE!" keyword.
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 05:38 AM
#16
Thread Starter
Fanatic Member
Re: How to save in Excel file
 Originally Posted by trisuglow
Read the Excel help - there is a section under the "#VALUE!" keyword.
The #VALUE! error value occurs when the wrong type of argument or operand is used
but there is some text only TEXT in text box Text2 .. then what could be the problem ...
I have checked by inserting small amount of text like 400 characters it is working well but when i insert more than 600 characters it starts to display #VALUE!.
-
Aug 15th, 2005, 06:03 AM
#17
Re: How to save in Excel file
Try creating a new spreadsheet and see what happens with that. I've just done exactly this and it works fine with long strings (>600 characters) of text. Let me know the result - if it works then try to work out what the difference is between the spreadsheets.
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 06:12 AM
#18
Thread Starter
Fanatic Member
Re: How to save in Excel file
 Originally Posted by trisuglow
Try creating a new spreadsheet and see what happens with that. I've just done exactly this and it works fine with long strings (>600 characters) of text. Let me know the result - if it works then try to work out what the difference is between the spreadsheets.
same problem
#VALUE!
Last edited by vbPoet; Aug 15th, 2005 at 06:27 AM.
-
Aug 15th, 2005, 06:14 AM
#19
Thread Starter
Fanatic Member
Re: How to save in Excel file
how long data Excel can support in one cell ..?
Last edited by vbPoet; Aug 15th, 2005 at 06:19 AM.
-
Aug 15th, 2005, 06:29 AM
#20
Re: How to save in Excel file
OK.
I opened Excel and created a new, blank spreadsheet and saved it as C:\Book1.xls.
Then I ran this code. None of the cells said #VALUE!
Can you do exactly the same thing? If you don't get the same result as me then Email me the spreadsheet and I'll try to see what is different.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim xl As New Excel.Application
Dim vLoop As Long
Dim vStr As String
xl.Workbooks.Open "C:\book1.xls"
For vLoop = 1 To 1000
vStr = vStr & "word "
xl.Worksheets(1).Cells(vLoop, 3).Formula = vStr
Next
xl.Save
xl.Quit
End Sub
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 06:40 AM
#21
Thread Starter
Fanatic Member
Re: How to save in Excel file
 Originally Posted by trisuglow
OK.
I opened Excel and created a new, blank spreadsheet and saved it as C:\Book1.xls.
Then I ran this code. None of the cells said #VALUE!
Can you do exactly the same thing? If you don't get the same result as me then Email me the spreadsheet and I'll try to see what is different.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim xl As New Excel.Application
Dim vLoop As Long
Dim vStr As String
xl.Workbooks.Open "C:\book1.xls"
For vLoop = 1 To 1000
vStr = vStr & "word "
xl.Worksheets(1).Cells(vLoop, 3).Formula = vStr
Next
xl.Save
xl.Quit
End Sub
OOPS
Your code is showing that u r changing rows as well
but i want to store 1000+characters in one cell...
i think that is the difference ...
-
Aug 15th, 2005, 06:50 AM
#22
Re: How to save in Excel file
But by the time the code I posted gets to row 1000 vStr will have built up to be 5000 characters long.
What happened when you tried what I suggested? Were you still getting #VALUE! ?
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 06:56 AM
#23
Thread Starter
Fanatic Member
Re: How to save in Excel file
Your code is working very well ....in Book1.xls
but #Value! in previous file is still unsolved.
-
Aug 15th, 2005, 06:59 AM
#24
Re: How to save in Excel file
So what are the differences between Book1.xls and the other spreadsheet you are using? If you want to post both spreadsheets I'll have a look for you if you can't see a difference.
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 07:14 AM
#25
Thread Starter
Fanatic Member
Re: How to save in Excel file
exactly nothing..
i cannot post spreadsheets becoz these are sensitive.
-
Aug 15th, 2005, 07:24 AM
#26
Re: How to save in Excel file
Well, there must be some difference - what happens when you run my code from post number 21 against your real spreadsheet - do you still get the #VALUE! ?
What happens if you delete all the data from your sensitive spreadsheet - do you still get the same problem? If so, can you post the spreadsheet with the data deleted?
This world is not my home. I'm just passing through.
-
Aug 15th, 2005, 07:33 AM
#27
Thread Starter
Fanatic Member
Re: How to save in Excel file
#21 code was tested with Book1.xls and it was quite good without any error.
but my original problem is with anyname.xls where data from text2 is going into column "A".
Text2 contains nearly 25 lines each line contain nearly 5-20 characters.
and line is separated with Chr(13) & Chr(10).
I don't know where is problem...
When i tested by reducing lines of Text2 to 10-13 it works good.but when i increase to 14-25...exactly same error returns back "#VALUE!"
Really Gettin Mad
-
Aug 15th, 2005, 07:38 AM
#28
Re: How to get rid of #VALUE!
The maximum number of characters a cell in Excel is 32,767... so it does not sound as though the problem is the contents in the cell as it should show this..
What are the first few charaacters you are sending? If this begins with "=" then that could be the problem, as excel is trying to evaluate a formula.
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 15th, 2005, 07:48 AM
#29
Thread Starter
Fanatic Member
Re: How to get rid of #VALUE!
No text2 contains
text data only
-
Aug 15th, 2005, 07:50 AM
#30
Re: How to get rid of #VALUE!
Ok then could you post a sample of the text data in text2?
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 15th, 2005, 07:56 AM
#31
Thread Starter
Fanatic Member
Re: How to get rid of #VALUE!
Thank You All
specially Trisuglow
it was trimming problem simply Bull****
Last edited by vbPoet; Aug 15th, 2005 at 08:00 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|