excel Vba copy paste to another workbook - copy

I need to copy a value on an activesheet cell A1, to another workbook located at d:\location\aaa.xls cell C3.
I just need it to paste special the values, if possible I do not want to have to open the workbook aaa.xls - i just need the values injected or at least open close.
TIA.

You have top open the aaa.xls in your current context to update any values in that file.

Related

Copy content from one nattable to other with same object type

Copy content (multiple rows) from one nattable to other. Both the nattables have same object type.
If you want to copy and paste something, you need to parse the content in the clipboard. NatTable does not support this out of the box. You will need to implement some paste command handler that can take content from the clipboard to create new objects with the data available in the clipboard.

How to change Excel 2013 Template Miniature

Is there a simple way to change / replace the automatically generated Template Miniature with a different image.
I have checked this out for Excel 2016 but the process is similar.
First, the thumbnail is generated and part of the file. There is no official process. A description for brave Office pros is shown below.
You can do this:
First, close Excel!
Get to the location of your template
Make a copy
Rename the file extension to .zip
Unzip the file into a new folder using the Windows Zip utility
Search the tree of files for a file called thumbnail.wmf
Open PowerPoint and create an empty presentation
Use the function "Insert an Image" and add the thumbnail.wmf to the slide
Remove everything else from the slide
Try to ungroup - it fails with a message asking to convert to a drawing object
From here you have two options. Either convert, ungroup, change and proceed or throw away and create a new image from scratch.
Work on image and group your image (the old or a new one), then
Right click on the grouped image and click "Save as picture"
Choose the filetype "wmf" and name it the same as before and overwrite the existing thumbnail.wmf
Go INTO the folder using Windows Explorer of unpacked files, hit Ctrl-A (Select All)
Right click and say "Send to" --> "Compressed (zipped) folder". Give it a new name.
Hit F2 to rename the file
Remove the file extension .zip
Now, open Excel!
Hit "New", "Personal" and you see your template with your custom image in full width and height. Repeat steps 10 to 16 until you're satisfied.
Drawbacks: Once you edit your file in excel and save as template with thumbnails option (advanced properties) switched on, Excel will overwrite your custom wmf-file. You have to repeat the steps "Unpack -> Replace File -> Pack" every time.
I'll post an update once I found a better solution.
Here is an automation of the process that might help with understanding the process described in the answer.
Python 3 code snippet
import zipfile
import shutil
exfilename = 'MYTEMPLATE.xltm'
a_path='C:\\TEMP'
th_path='mythumbnail.wmf'
with zipfile.ZipFile (exfilename, 'r') as zf:
#Extract to temporary folder
zf.extractall(a_path)
#replace the thumbnail
shutil.copyfile(th_path,a_path+'\\docProps\\thumbnail.wmf')
#remake the zip as a new file
shutil.make_archive('TEMP_ARCHIVE','zip',a_path)
#rename back to original, replacing original
shutil.move('TEMP_ARCHIVE.zip',exfilename)
#clean-up temporary files
shutil.rmtree(a_path)

See raw code/text from copy paste

I doing some formatting from copy/paste. When I copy a table from Word, and I want to insert it in my program, I need to edit the table formatting to show the info like I want.
When I copy from word I can view whats copy in clipboard magic:
Is there a way to get the formatting, or do I need to create a new table for scratch with the data listed in clipboard magic?
I Clipdiary the "copy" is read as HTML
This makes me wounder, is it possible to get the html code?
Yes, the HTML is present as CF_HTML. See reference on MSDN: http://msdn.microsoft.com/en-us/library/aa767917(v=vs.85).aspx
If you just want to SEE it, ClipMate has a Binary display that will show you a binary dump of the data. It's available in the trial version. If you don't see the Binary tab in the display window, turn it on in the Tools | Options | Editor dialog.

Macro in QAT not referenced to saved workbook

I have an excel template that has a macro button in the quick access toolbar (QAT). When I save the template as an Excel Macro Enabled Workbook, the button found in the QAT is linked back to the macro in the original template, not the macro found in the new file I just saved. Is there a way I can get the QAT toolbar in this new file to reference the macro in the saved file instead of original template?
I figure it out finally. I needed to add it for the current document only, not all documents (default). Opposite of what I intuitively thought. It probably has something to do with how the macros are stored with each option.

How do I create a text file so when it is opened in Excel, rows are grouped together?

I'm collecting some data via a Perl script. The data needs to be reviewed and processed by others using Excel. Currently, I'm writing the data out as a tab-delimited text file, and Excel can open this just fine.
There's a hierarchy to the data, however, and it would be easier for the reviewers to see a tree rather than a flat list. That is, rather than presenting the data in columns,
foo foo1
foo foo2
foo foo3
bar bar1
bar bar2
...
present it as a click-to-expand tree:
foo
foo1
foo2
foo3
bar
bar1
bar2
...
Excel's group function (found in 2007 under "Data > Outline > Group") is a good match for this presentation, being a bit simpler to operate than pivot tables.
What is the easiest way for us to go from this flat list of columns to this grouped list? Ideally, I could write out the data in a text form that Excel would apply the grouping automatically when it was imported. Alternatively, if there were a small number of steps the reviewer could apply after importing the data, like applying a macro or a template, that would be OK too.
Since you are already using perl, I suggest that you create the excel file directly in perl using the excellent CPAN module Spreadsheet::WriteExcel which has support for Excel outlines.
Works something like this:
.
.
$worksheet->write('A2', 'foo');
$worksheet->write('B3', 'foo1');
$worksheet->write('B4', 'foo2');
$worksheet->write('B5', 'foo3');
$worksheet->set_row(2, undef, undef, 0, 1, 1);
$worksheet->set_row(3, undef, undef, 0, 2);
$worksheet->set_row(4, undef, undef, 0, 2);
$worksheet->set_row(5, undef, undef, 0, 2);
.
.
Select all the rows, including the column headers, in the list you want to filter.
ShowTip
Click the top left cell of the range, and then drag to the bottom right cell.
On the Data menu, point to Filter, and then click Advanced Filter.
In the Advanced Filter dialog box, click Filter the list, in place.
Select the Unique records only check box, and then click OK.
The filtered list is displayed and the duplicate rows are hidden.
On the Edit menu, click Office Clipboard.
The Clipboard task pane is displayed.
Make sure the filtered list is still selected, and then click Copy Copy button.
The filtered list is highlighted with bounding outlines and the selection appears as an item at the top of the Clipboard.
On the Data menu, point to Filter, and then click Show All.
The original list is re-displayed.
Press the DELETE key.
The original list is deleted.
In the Clipboard, click on the filtered list item.
The filtered list appears in the same location as the original list.
Recent versions of Excel (2003 is what we use here) can use an XML format, xlsx. An xlsx file is a zip of an XML file. If you want to make a file that will open in Excel with the settings you want, try this: first create a template file with the grouping you want. Save it as xlsx. Unzip the file using your standard zip software. Take a look at what's inside. I haven't worked with grouping specifically, but all the commands in your spreadsheet will be there in xml form, you'll need to figure out where the grouping is set. Then it's a matter of making the appropriate changes to the xml and re-zipping. A bit of effort, but you can use this method to programmatically create files that are pre-grouped. There may be Perl libraries specifically geared towards this, I don't know.
A CSV file is also very easy to generate. OpenOffice lets you choose how to parse things, but excel excepts comma-delimited columns (without any kind of quote) and CRLF delimited rows.
A1,A2,A3
B1,B2,B3
etc.