This is a pretty simple question but I cant figure it out. Im not the greatest programmer.
What Im writing my program to do is copy certains words, phrases, sentences from a Word Document and pasting them into specific rows and columns of an excel spreadsheet.
Ive pretty much figured out everything except for one major problem. Lets say Im copying the phrase...
"Hello world
How are you?"
Now if i just selected a cell, it wouldnt copy it all into that one cell. The first row would say "Hello world", the 2nd row would be blank, and the 3rd row would say "How are you?". If you want it all in one cell, you have to double click with your mouse on the cell to get the cursor blinking inside. And my question is, how can I tell my program to do that? I can select any cell i want, but i dont know the code to be able to get the cursor blinking inside.
I recorded a Macro in excel which I thought could help. But whenever I double clicked in a cell, it never let me stop recording while the cursor was blinking inside. I always had to get out of the cell before I could stop recording. And the Macro would say ActiveCell.FormulaR1C1 = "whatever i typed". I tried writing wks.application.ActiveCell.Value2 = .... but that was asking for an object(wks is my worksheet). I couldnt set that equal to wks.Paste() obviously cuz thats a void and Value2 is asking for an object.
Then I tried seeing if I could just write in my program some code telling it to double click as if I was using a mouse. I wrote....
System.Windows.Forms.MouseButtons left = System.Windows.Forms.MouseButtons.Left;
new System.Windows.Forms.MouseEventArgs(left, 2, 0, 0, 0);
But none of that worked. Im not really sure how those MouseButton and MouseEvent things work.
Originally, I had just saved what I wanted in my Word document to a string file and then wrote what was in my string to wherever I wanted in the excel. But in a string file, you cant have ENTER spaces. So when it pasted over to the excel, it would give me weird symbols and it looked pretty bad.
So does anyone have any advice? Is there a way to write code to get the cursor inside the cell without double clicking the mouse? Is there a way to write the code to just tell it to double click as if using a mouse? any other suggestions would be appreciated. Thanks.
What Im writing my program to do is copy certains words, phrases, sentences from a Word Document and pasting them into specific rows and columns of an excel spreadsheet.
Ive pretty much figured out everything except for one major problem. Lets say Im copying the phrase...
"Hello world
How are you?"
Now if i just selected a cell, it wouldnt copy it all into that one cell. The first row would say "Hello world", the 2nd row would be blank, and the 3rd row would say "How are you?". If you want it all in one cell, you have to double click with your mouse on the cell to get the cursor blinking inside. And my question is, how can I tell my program to do that? I can select any cell i want, but i dont know the code to be able to get the cursor blinking inside.
I recorded a Macro in excel which I thought could help. But whenever I double clicked in a cell, it never let me stop recording while the cursor was blinking inside. I always had to get out of the cell before I could stop recording. And the Macro would say ActiveCell.FormulaR1C1 = "whatever i typed". I tried writing wks.application.ActiveCell.Value2 = .... but that was asking for an object(wks is my worksheet). I couldnt set that equal to wks.Paste() obviously cuz thats a void and Value2 is asking for an object.
Then I tried seeing if I could just write in my program some code telling it to double click as if I was using a mouse. I wrote....
System.Windows.Forms.MouseButtons left = System.Windows.Forms.MouseButtons.Left;
new System.Windows.Forms.MouseEventArgs(left, 2, 0, 0, 0);
But none of that worked. Im not really sure how those MouseButton and MouseEvent things work.
Originally, I had just saved what I wanted in my Word document to a string file and then wrote what was in my string to wherever I wanted in the excel. But in a string file, you cant have ENTER spaces. So when it pasted over to the excel, it would give me weird symbols and it looked pretty bad.
So does anyone have any advice? Is there a way to write code to get the cursor inside the cell without double clicking the mouse? Is there a way to write the code to just tell it to double click as if using a mouse? any other suggestions would be appreciated. Thanks.