How to get long text from the clipboard into Navision variable

intron
Member Posts: 3
Hello everyone
I have read some discussions on this forum but i didn't find solution.
I need to take long text from clipboard into variables.
I read on this forum about this OCX:
http://www.mibuso.com/dlinfo.asp?FileID=149
and I tried to use it but it work fine only when the text length in clipboard is less than 255 characters.
(I would split the clipboard text to couples text variables or use one text variable with couples dimensions - that’s not a problem)
Example:
Code below works fine where in my clipboard contain text till 254 characters.
i := STRLEN(Clipboard.TextFromClipboard);
If I copy to clipboard 255 characters (or more) the line above gives an error:
The length of the text string exceeds the size of the string buffer.
Thanks for any suggestion. Maybe I could you some different OCX /solution ?
I have read some discussions on this forum but i didn't find solution.
I need to take long text from clipboard into variables.
I read on this forum about this OCX:
http://www.mibuso.com/dlinfo.asp?FileID=149
and I tried to use it but it work fine only when the text length in clipboard is less than 255 characters.
(I would split the clipboard text to couples text variables or use one text variable with couples dimensions - that’s not a problem)
Example:
Code below works fine where in my clipboard contain text till 254 characters.
i := STRLEN(Clipboard.TextFromClipboard);
If I copy to clipboard 255 characters (or more) the line above gives an error:
The length of the text string exceeds the size of the string buffer.
Thanks for any suggestion. Maybe I could you some different OCX /solution ?
0
Answers
-
Hi,
I've had similar problem and solved it using Excel and Excel Buffer.
This is a simple code skeleton:CREATE(XlApp, FALSE); XlApp.Visible(FALSE); XlWrkBk := XlApp.Workbooks.Add; XlWrkSht := XlWrkBk.Worksheets.Add; XlWrkSht.Paste; //this inserts your clipboard into A1 cell MyText := COPYSTR(FORMAT(XlWrkSht.Range('A1').Value), 1, 1024); XlWrkBk.Close; CLEAR(XlApp);
There are certain problems with this approach, if your text in clipboard includes tabs pasted text will be spread among columns, if your text in clipboard includes new lines pasted text will be spread across some rows.
But at least it is a starting point.
NB: XL* variables are copied from Excle Buffer table.
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-031 -
Thank you for your answer Sławek.
That’s quite clever solution of this topic but as you mention, there are some disadvantages of such approach.
As I think, to use this solution, client has to have Excel installed on local computer. In my case, Excel can’t be installed (for some reasons).
I will think more how to “adjust” your idea. Thanks once again.
BTW.
It could be added one more line:
XlApp.DisplayAlerts(FALSE);
before closing workbook. That will hide Excel question window if you want to save workbook.
Any other ideas ?
Piotr
0 -
It's not exact code I'm using, it was just a skeleton, to show what's possible.
I'd rather try to stay away from 3rd party OCX or dlls as they also needs to be installed on client's PC, and that's often harder to get installed than the Excel.
Another idea? What about writting your own small DLL reading from and/or writting to clipboard? There are a few templates around of dlls which can be seen by Classic Client.
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
I did not figure better solution out. I will go forward with your Excel solution.
Thank you Sławek.
0 -
Why not use a dotnet variable for this:
Clipboard msdn0 -
Remco_Reinking wrote: »Why not use a dotnet variable for this:
Clipboard msdnSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Slawek_Guzek wrote: »Remco_Reinking wrote: »Why not use a dotnet variable for this:
Clipboard msdn
Yeah, makes sense0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions