KfirAsulin Posted May 26, 2020 Posted May 26, 2020 Hello, I would like to copy a list view and past it ( to word or outlook) so it is pasted as a table - the same way it is presented in the control.
Moderators Melba23 Posted May 26, 2020 Moderators Posted May 26, 2020 Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Nine Posted May 26, 2020 Posted May 26, 2020 What have you tried so far ? Maybe copy/paste is not the best approach, hard to say. What is the source ListView, your own GUI or another application. Please post the code you have, so we can understand your issue. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
KfirAsulin Posted May 26, 2020 Author Posted May 26, 2020 I start with creating a list vew as follows: $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Item 1") _GUICtrlListView_AddItem($idListview, "Item 2") _GUICtrlListView_AddItem($idListview, "Item 3")........ .... .... Then, after the list view has values, I would like to copy its data and paste it (to Word Document) so the data will show also as a table (like a table created by Word). Is it possible?
Nine Posted May 26, 2020 Posted May 26, 2020 I think that the easiest approach is to parse your entire List View into a 2D array and use Word UDF _Word_DocTableWrite function to write it at once into a document. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
MrCreatoR Posted May 26, 2020 Posted May 26, 2020 3 hours ago, Nine said: easiest approach is to parse your entire List View into a 2D array and use Word UDF _Word_DocTableWrite function to write it at once into a document Yep, something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> #include <Word.au3> Global $sFile = @DesktopDir & '\Test.doc' $hGUI = GUICreate('Test', 240, 300) $iLV = GUICtrlCreateListView('Col1|Col2|Col3', 20, 20, 200, 240) For $i = 1 To 10 GUICtrlCreateListViewItem('Item' & $i & '|SubItem 1|SubItem 2', $iLV) Next $iCopy_Bttn = GUICtrlCreateButton('Copy to word', 20, 270, 80, 20) $iStatus_Lbl = GUICtrlCreateLabel('', 110, 273, 100, 15) GUICtrlSetColor(-1, 0xFF0000) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iCopy_Bttn Local $iCount = _GUICtrlListView_GetItemCount($iLV) Dim $aTable[$iCount][3] = [[$iCount]] For $i = 0 To $iCount - 1 For $j = 0 To 2 $aTable[$i][$j] = _GUICtrlListView_GetItemText($iLV, $i, $j) Next Next GUICtrlSetData($iStatus_Lbl, 'Please wait...') FileClose(FileOpen($sFile, 2)) ;2 - Rewrite, use 1 to append Local $oWord = _Word_Create(False, True) Local $oDoc = _Word_DocOpen($oWord, $sFile) Local $oRange = _Word_DocRangeSet($oDoc, -2) _Word_DocTableWrite($oRange, $aTable, 0) _Word_DocClose($oDoc, $WdSaveChanges) _Word_Quit($oWord) GUICtrlSetData($iStatus_Lbl, '') EndSwitch WEnd But still it's also interesting for me to find a way to actually put the table to the clipboard (as RTF format for example) without using external tools. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now