Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
Hey guys,
Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
Thanks for your answer. In case I didn't explain it clear before I will try
to reformulate the problem... - Cells T1...500 in EXCEL contains a paragraph of text of whatever lenght (it is not known beforehand!) that has to be copied in a form in word. - The field Text3 is the field in the WORD form where I want to copy the text from the previous cell (there is one field for each cell). Depending on the length of the content of the text in the cells T1...500, the follwowing routine works or not ... If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If If the text in the EXCEL cell is long enough, the previous routine fails in execution because wdFF.Result is expecting to see a String and seems the text in the cell is too long for a string. Any idea of how to avoid this problem? "Nigel" wrote: The result of the evaluation of Range("T" & fila) presumably returns a string? What do you mean when you say "the info received is much longer", a string is a string! Long vars refer to a numerical value not a string. You could convert the value to a string using Cstr(Range("T" & fila)) but you probably need some error checking to avoid error values, nulls etc. -- Regards, Nigel "Ruth" wrote in message ... Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
I am no expert on WORD, this appears to be an issue in that application not
Excel. If the text is already stored in an Excel cell then you have not exceeded any limits, and string var will handle that length of string. So it must be a limit in Word. Have you tried the word programming newsgroup ? Sorry I do not have a specific solution -- Regards, Nigel "Ruth" wrote in message ... Thanks for your answer. In case I didn't explain it clear before I will try to reformulate the problem... - Cells T1...500 in EXCEL contains a paragraph of text of whatever lenght (it is not known beforehand!) that has to be copied in a form in word. - The field Text3 is the field in the WORD form where I want to copy the text from the previous cell (there is one field for each cell). Depending on the length of the content of the text in the cells T1...500, the follwowing routine works or not ... If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If If the text in the EXCEL cell is long enough, the previous routine fails in execution because wdFF.Result is expecting to see a String and seems the text in the cell is too long for a string. Any idea of how to avoid this problem? "Nigel" wrote: The result of the evaluation of Range("T" & fila) presumably returns a string? What do you mean when you say "the info received is much longer", a string is a string! Long vars refer to a numerical value not a string. You could convert the value to a string using Cstr(Range("T" & fila)) but you probably need some error checking to avoid error values, nulls etc. -- Regards, Nigel "Ruth" wrote in message ... Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
Hello again Ruth
It seems that the fact you;re doing it from Excel is irrelevant here - you can't directly set a text formfield to more than 255 characters, though you can do it "manually" within Word. See this MS article, which gives a rather klunky workaround: http://support.microsoft.com/default...;en-us;Q163192 (using search and replace in the field) See also http://groups.google.co.uk/group/mic...5eaf7882ecba1c which has a different method using copy & paste. Andrew On 11 Jan, 11:04, Ruth wrote: Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
It seems to be a problem in EXCEL, and most likely the problem is that I
haven't defined something properly but I don't know exactly what. "Nigel" wrote: I am no expert on WORD, this appears to be an issue in that application not Excel. If the text is already stored in an Excel cell then you have not exceeded any limits, and string var will handle that length of string. So it must be a limit in Word. Have you tried the word programming newsgroup ? Sorry I do not have a specific solution -- Regards, Nigel "Ruth" wrote in message ... Thanks for your answer. In case I didn't explain it clear before I will try to reformulate the problem... - Cells T1...500 in EXCEL contains a paragraph of text of whatever lenght (it is not known beforehand!) that has to be copied in a form in word. - The field Text3 is the field in the WORD form where I want to copy the text from the previous cell (there is one field for each cell). Depending on the length of the content of the text in the cells T1...500, the follwowing routine works or not ... If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If If the text in the EXCEL cell is long enough, the previous routine fails in execution because wdFF.Result is expecting to see a String and seems the text in the cell is too long for a string. Any idea of how to avoid this problem? "Nigel" wrote: The result of the evaluation of Range("T" & fila) presumably returns a string? What do you mean when you say "the info received is much longer", a string is a string! Long vars refer to a numerical value not a string. You could convert the value to a string using Cstr(Range("T" & fila)) but you probably need some error checking to avoid error values, nulls etc. -- Regards, Nigel "Ruth" wrote in message ... Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
Looks like Andrew Taylor has put his finger on it. Its a WORD problem
-- Regards, Nigel "Ruth" wrote in message ... It seems to be a problem in EXCEL, and most likely the problem is that I haven't defined something properly but I don't know exactly what. "Nigel" wrote: I am no expert on WORD, this appears to be an issue in that application not Excel. If the text is already stored in an Excel cell then you have not exceeded any limits, and string var will handle that length of string. So it must be a limit in Word. Have you tried the word programming newsgroup ? Sorry I do not have a specific solution -- Regards, Nigel "Ruth" wrote in message ... Thanks for your answer. In case I didn't explain it clear before I will try to reformulate the problem... - Cells T1...500 in EXCEL contains a paragraph of text of whatever lenght (it is not known beforehand!) that has to be copied in a form in word. - The field Text3 is the field in the WORD form where I want to copy the text from the previous cell (there is one field for each cell). Depending on the length of the content of the text in the cells T1...500, the follwowing routine works or not ... If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If If the text in the EXCEL cell is long enough, the previous routine fails in execution because wdFF.Result is expecting to see a String and seems the text in the cell is too long for a string. Any idea of how to avoid this problem? "Nigel" wrote: The result of the evaluation of Range("T" & fila) presumably returns a string? What do you mean when you say "the info received is much longer", a string is a string! Long vars refer to a numerical value not a string. You could convert the value to a string using Cstr(Range("T" & fila)) but you probably need some error checking to avoid error values, nulls etc. -- Regards, Nigel "Ruth" wrote in message ... Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
Hi Andrew
Thanks a lot for your help! I had a look to the links and I decided to go for the second one but still struggling with some problems. Case "Text3" If Len(Range("T" & fila)) 255 Then wdFF.Result = Left$(Range("T" & fila), 250) MyDataObj.SetText "" MyDataObj.PutInClipboard MyDataObj.SetText Mid$(Range("T" & fila), 256) MyDataObj.PutInClipboard Set rngx = wdFF.Range rngx.GoTo rngx.Select With wordFile.Selection .Collapse wdCollapseEnd .Paste End With Else wdFF.Result = Range("T" & fila) End If The situation now is that I get the 255 initial characters, it even clear properly the clipboard and copy there the rest of the text but then I get an error because it says that "Set rngx = wdFF.Range" use non compatible formats (rngx is defined as a range). Any idea of what I coud do? Thanks!! "Andrew Taylor" wrote: Hello again Ruth It seems that the fact you;re doing it from Excel is irrelevant here - you can't directly set a text formfield to more than 255 characters, though you can do it "manually" within Word. See this MS article, which gives a rather klunky workaround: http://support.microsoft.com/default...;en-us;Q163192 (using search and replace in the field) See also http://groups.google.co.uk/group/mic...5eaf7882ecba1c which has a different method using copy & paste. Andrew On 11 Jan, 11:04, Ruth wrote: Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
On 12 Jan., 18:44, Ruth wrote:
Hi Andrew Thanks a lot for your help! I had a look to the links and I decided to go for the second one but still struggling with some problems. Case "Text3" * * * * * * * * *If Len(Range("T" & fila)) 255 Then * * * * * * * * * wdFF.Result = Left$(Range("T" & fila), 250) * * * * * * * * * MyDataObj.SetText "" * * * * * * * * * MyDataObj.PutInClipboard * * * * * * * * * MyDataObj.SetText Mid$(Range("T" & fila), 256) * * * * * * * * * MyDataObj.PutInClipboard * * * * * * * * * Set rngx = wdFF.Range * * * * * * * * * rngx.GoTo * * * * * * * * * rngx.Select * * * * * * * * * With wordFile.Selection * * * * * * * * * * .Collapse wdCollapseEnd * * * * * * * * * * .Paste * * * * * * * * * End With * * * * * * * * Else * * * * * * * * * *wdFF.Result = Range("T" & fila) * * * * * * * * End If The situation now is that I get the 255 initial characters, it even clear properly the clipboard and copy there the rest of the text but then I get an error because it says that "Set rngx = wdFF.Range" use non compatible formats (rngx is defined as a range). Any idea of what I coud do? *Thanks!! "Andrew Taylor" wrote: Hello again Ruth It seems that the fact you;re doing it from Excel is irrelevant here - you *can't directly set a text formfield to more than 255 characters, though you can do it "manually" within Word. See this MS article, which gives a rather klunky workaround: http://support.microsoft.com/default...;en-us;Q163192 (using search and replace in the field) See also http://groups.google.co.uk/group/mic...vba/browse_thr... which has a different method using copy & paste. Andrew On 11 Jan, 11:04, Ruth wrote: Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!!- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - Hi again Just a long shot, maybe this will work ? Case "Text3" If Len(Range("T" & fila)) 255 Then wdFF.Result = Left$(Range("T" & fila), 250) ' Shoulden´t it be 255? MyDataObj.SetText "" MyDataObj.PutInClipboard DataString = Mid$(Range("T" & fila), 256) With wdFF .InsertAfter DataString .Collapse wdCollapseEnd End With Else wdFF.Result = Range("T" & fila) End If Regards, Per |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
Hi Per
Thanks for your answer!! Still has the same problem. I get a runtime error 438, "OBject doesn't support this property or method" when the execution goes through the sentence With wdFF .Insert DataString. Just to remind that wdFF is defined as an Object In wordFile.FormFields. Any idea of how to solve this and the reason of the error? "Per Jessen" wrote: On 12 Jan., 18:44, Ruth wrote: Hi Andrew Thanks a lot for your help! I had a look to the links and I decided to go for the second one but still struggling with some problems. Case "Text3" If Len(Range("T" & fila)) 255 Then wdFF.Result = Left$(Range("T" & fila), 250) MyDataObj.SetText "" MyDataObj.PutInClipboard MyDataObj.SetText Mid$(Range("T" & fila), 256) MyDataObj.PutInClipboard Set rngx = wdFF.Range rngx.GoTo rngx.Select With wordFile.Selection .Collapse wdCollapseEnd .Paste End With Else wdFF.Result = Range("T" & fila) End If The situation now is that I get the 255 initial characters, it even clear properly the clipboard and copy there the rest of the text but then I get an error because it says that "Set rngx = wdFF.Range" use non compatible formats (rngx is defined as a range). Any idea of what I coud do? Thanks!! "Andrew Taylor" wrote: Hello again Ruth It seems that the fact you;re doing it from Excel is irrelevant here - you can't directly set a text formfield to more than 255 characters, though you can do it "manually" within Word. See this MS article, which gives a rather klunky workaround: http://support.microsoft.com/default...;en-us;Q163192 (using search and replace in the field) See also http://groups.google.co.uk/group/mic...vba/browse_thr... which has a different method using copy & paste. Andrew On 11 Jan, 11:04, Ruth wrote: Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!!- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - Hi again Just a long shot, maybe this will work ? Case "Text3" If Len(Range("T" & fila)) 255 Then wdFF.Result = Left$(Range("T" & fila), 250) ' Shoulden´t it be 255? MyDataObj.SetText "" MyDataObj.PutInClipboard DataString = Mid$(Range("T" & fila), 256) With wdFF .InsertAfter DataString .Collapse wdCollapseEnd End With Else wdFF.Result = Range("T" & fila) End If Regards, Per |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
On 13 Jan., 02:43, Ruth wrote:
Hi Per Thanks for your answer!! Still has the same problem. I get a runtime error 438, "OBject doesn't support this property or method" when the execution goes through the sentence With wdFF *.Insert DataString. Just to remind that wdFF is defined as an Object In wordFile.FormFields. Any idea of how to solve this and the reason of the error? "Per Jessen" wrote: On 12 Jan., 18:44, Ruth wrote: Hi Andrew Thanks a lot for your help! I had a look to the links and I decided to go for the second one but still struggling with some problems. Case "Text3" * * * * * * * * *If Len(Range("T" & fila)) 255 Then * * * * * * * * * wdFF.Result = Left$(Range("T" & fila), 250) * * * * * * * * * MyDataObj.SetText "" * * * * * * * * * MyDataObj.PutInClipboard * * * * * * * * * MyDataObj.SetText Mid$(Range("T" & fila), 256) * * * * * * * * * MyDataObj.PutInClipboard * * * * * * * * * Set rngx = wdFF.Range * * * * * * * * * rngx.GoTo * * * * * * * * * rngx.Select * * * * * * * * * With wordFile.Selection * * * * * * * * * * .Collapse wdCollapseEnd * * * * * * * * * * .Paste * * * * * * * * * End With * * * * * * * * Else * * * * * * * * * *wdFF.Result = Range("T" & fila) * * * * * * * * End If The situation now is that I get the 255 initial characters, it even clear properly the clipboard and copy there the rest of the text but then I get an error because it says that "Set rngx = wdFF.Range" use non compatible formats (rngx is defined as a range). Any idea of what I coud do? *Thanks!! "Andrew Taylor" wrote: Hello again Ruth It seems that the fact you;re doing it from Excel is irrelevant here - you *can't directly set a text formfield to more than 255 characters, though you can do it "manually" within Word. See this MS article, which gives a rather klunky workaround: http://support.microsoft.com/default...;en-us;Q163192 (using search and replace in the field) See also http://groups.google.co.uk/group/mic...vba/browse_thr.... which has a different method using copy & paste. Andrew On 11 Jan, 11:04, Ruth wrote: Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!!- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - Hi again Just a long shot, maybe this will work ? Case "Text3" * * If Len(Range("T" & fila)) 255 Then * * * * wdFF.Result = Left$(Range("T" & fila), 250) ' Shoulden´t it be 255? * * * * MyDataObj.SetText "" * * * * MyDataObj.PutInClipboard * * * * DataString = Mid$(Range("T" & fila), 256) * * * * With wdFF * * * * * * .InsertAfter DataString * * * * * * .Collapse wdCollapseEnd * * * * End With * * Else * * * * wdFF.Result = Range("T" & fila) * * End If Regards, Per- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - Hi Ruth Thanks for your reply. Unfortunately I can't find any solution for your problem :-( I don't think that wdFF as Object is the problem, rather we are not using the right syntax to do what we want with the object. Regards, Per |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
On 13 Jan., 05:23, Per Jessen wrote:
On 13 Jan., wrote: Hi Per Thanks for your answer!! Still has the same problem. I get a runtime error 438, "OBject doesn't support this property or method" when the execution goes through the sentence With wdFF *.Insert DataString. Just to remind that wdFF is defined as an Object In wordFile.FormFields. Any idea of how to solve this and the reason of the error? "Per Jessen" wrote: On 12 Jan., wrote: Hi Andrew Thanks a lot for your help! I had a look to the links and I decided to go for the second one but still struggling with some problems. Case "Text3" * * * * * * * * *If Len(Range("T" & fila)) 255 Then * * * * * * * * * wdFF.Result = Left$(Range("T" & fila), 250) * * * * * * * * * MyDataObj.SetText "" * * * * * * * * * MyDataObj.PutInClipboard * * * * * * * * * MyDataObj.SetText Mid$(Range("T" & fila), 256) * * * * * * * * * MyDataObj.PutInClipboard * * * * * * * * * Set rngx = wdFF.Range * * * * * * * * * rngx.GoTo * * * * * * * * * rngx.Select * * * * * * * * * With wordFile.Selection * * * * * * * * * * .Collapse wdCollapseEnd * * * * * * * * * * .Paste * * * * * * * * * End With * * * * * * * * Else * * * * * * * * * *wdFF.Result = Range("T" & fila) * * * * * * * * End If The situation now is that I get the 255 initial characters, it even clear properly the clipboard and copy there the rest of the text but then I get an error because it says that "Set rngx = wdFF.Range" use non compatible formats (rngx is defined as a range). Any idea of what I coud do? *Thanks!! "Andrew Taylor" wrote: Hello againRuth It seems that the fact you;re doing it from Excel is irrelevant here - you *can't directly set a text formfield to more than 255 characters, though you can do it "manually" within Word. See this MS article, which gives a rather klunky workaround: http://support.microsoft.com/default...;en-us;Q163192 (using search and replace in the field) See also http://groups.google.co.uk/group/mic...vba/browse_thr... which has a different method using copy & paste. Andrew On 11 Jan, wrote: Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted.. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!!- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - Hi again Just a long shot, maybe this will work ? Case "Text3" * * If Len(Range("T" & fila)) 255 Then * * * * wdFF.Result = Left$(Range("T" & fila), 250) ' Shoulden´t it be 255? * * * * MyDataObj.SetText "" * * * * MyDataObj.PutInClipboard * * * * DataString = Mid$(Range("T" & fila), 256) * * * * With wdFF * * * * * * .InsertAfter DataString * * * * * * .Collapse wdCollapseEnd * * * * End With * * Else * * * * wdFF.Result = Range("T" & fila) * * End If Regards, Per- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - HiRuth Thanks for your reply. Unfortunately I can't find any solution for your problem :-( I don't think that wdFF as Object is the problem, rather we are not using the right syntax to do what we want with the object. Regards, Per- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - Hi Ruth I have found a workaround, that will work if the text passed to your Form won't be manipulated. Insert at new Text Form Field next to the field named "Text1" and name it "Text1_1", and use this code: Case "Text1" If Len(Range("T" & fila)) 255 Then wdFF.Result = Left$(Range("T" & fila), 250) ' Shoulden´t it be 255 DataString = Mid$(Range("T" & fila), 256) wordFile.FormFields("Text1_1").Result = DataString Else wdFF.Result = Range("T" & fila) End If Regards, Per |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
You say "rngx is defined as a range" - does this mean
you have "Dim rngx as Range" in your Excel code? That is not the same as a Range object in Word - you should probably make "Dim rngx as Word.Range" Andrew On 12 Jan, 17:44, Ruth wrote: Hi Andrew Thanks a lot for your help! I had a look to the links and I decided to go for the second one but still struggling with some problems. Case "Text3" If Len(Range("T" & fila)) 255 Then wdFF.Result = Left$(Range("T" & fila), 250) MyDataObj.SetText "" MyDataObj.PutInClipboard MyDataObj.SetText Mid$(Range("T" & fila), 256) MyDataObj.PutInClipboard Set rngx = wdFF.Range rngx.GoTo rngx.Select With wordFile.Selection .Collapse wdCollapseEnd .Paste End With Else wdFF.Result = Range("T" & fila) End If The situation now is that I get the 255 initial characters, it even clear properly the clipboard and copy there the rest of the text but then I get an error because it says that "Set rngx = wdFF.Range" use non compatible formats (rngx is defined as a range). Any idea of what I coud do? Thanks!! "Andrew Taylor" wrote: Hello again Ruth It seems that the fact you;re doing it from Excel is irrelevant here - you can't directly set a text formfield to more than 255 characters, though you can do it "manually" within Word. See this MS article, which gives a rather klunky workaround: http://support.microsoft.com/default...;en-us;Q163192 (using search and replace in the field) See also http://groups.google.co.uk/group/mic...vba/browse_thr... which has a different method using copy & paste. Andrew On 11 Jan, 11:04, Ruth wrote: Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
String vs LONG format
Hi Andrew,
Yes I did and it is not the same. Thanks for the help! Now seems to be completly working. Per, the problem with the approach that you suggest is that it is more than 510 characters then you have to include a third field and so on, ... This is the code I finally used and it is working .... If Len(Range("T" & fila)) 255 Then wdFF.Result = Left$(Range("T" & fila), 255) MyDataObj.SetText "" MyDataObj.PutInClipboard MyDataObj.SetText Mid$(Range("T" & fila), 1) MyDataObj.PutInClipboard wordFile.Unprotect Set rngx = wdFF.Range rngx.GoTo rngx.Select rngx.Paste wordFile.Protect Type:=2, NoReset:=1 Else wdFF.Result = Range("T" & fila) End If Of course rngx not defined as an excel range!! Well, thanks to all you guys for your help!! "Andrew Taylor" wrote: You say "rngx is defined as a range" - does this mean you have "Dim rngx as Range" in your Excel code? That is not the same as a Range object in Word - you should probably make "Dim rngx as Word.Range" Andrew On 12 Jan, 17:44, Ruth wrote: Hi Andrew Thanks a lot for your help! I had a look to the links and I decided to go for the second one but still struggling with some problems. Case "Text3" If Len(Range("T" & fila)) 255 Then wdFF.Result = Left$(Range("T" & fila), 250) MyDataObj.SetText "" MyDataObj.PutInClipboard MyDataObj.SetText Mid$(Range("T" & fila), 256) MyDataObj.PutInClipboard Set rngx = wdFF.Range rngx.GoTo rngx.Select With wordFile.Selection .Collapse wdCollapseEnd .Paste End With Else wdFF.Result = Range("T" & fila) End If The situation now is that I get the 255 initial characters, it even clear properly the clipboard and copy there the rest of the text but then I get an error because it says that "Set rngx = wdFF.Range" use non compatible formats (rngx is defined as a range). Any idea of what I coud do? Thanks!! "Andrew Taylor" wrote: Hello again Ruth It seems that the fact you;re doing it from Excel is irrelevant here - you can't directly set a text formfield to more than 255 characters, though you can do it "manually" within Word. See this MS article, which gives a rather klunky workaround: http://support.microsoft.com/default...;en-us;Q163192 (using search and replace in the field) See also http://groups.google.co.uk/group/mic...vba/browse_thr... which has a different method using copy & paste. Andrew On 11 Jan, 11:04, Ruth wrote: Hey guys, Any idea about how to solve this? I want to copy some cells in EXCEL to a form in WORD. The problem is when the cells in EXCEL contain some long paragraphs of text. I have done it in the following way: If wdFF.Name = "Text3" Then wdFF.Result = Range("T" & fila) End If Text3 is the field in the form where the info should be inserted. If I copy and paste manually the info to the field in the form it works fine but with the code above it does not work because it seems the object wdFF is expecting to see only a string and the info received is much longer. Is there any way to modify the format of the object wdFF from string to long?? or should I cut and put together later on? Thanks!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
long text string | Excel Programming | |||
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) | Excel Programming | |||
Importing Long String - String Manipulation (EDI EANCOM 96a) | Excel Programming | |||
From String to Long | Excel Programming | |||
converting a string to long | Excel Programming |