Convert an excel range into image without copy and paste - excel

I am looking for a solution were a given excel range can be converted to an image without copy and paste or without putting anything in clipboard.
The reason for this is because the VBA code will be running in the background and the user will continue their regular work. So when they do any copy and paste activity happens 'oRange.CopyPicture xlScreen, xlPicture' code hits an error.
The tool will run every 60 seconds.
I have checked a lot of web portals to find an answer, but most of them are limited to 'CopyPicture'. One webpage example given below.
http://vbadud.blogspot.com/2010/06/how-to-save-excel-range-as-image-using.html
Can someone please help me.

Found a solution, might not directly solve this. I have created another instance of windows log in and run this Marco at regular intervals in that instance.
This way we have two different clip boards that will not conflict.

Related

Combination of alt+TAB and alt+e+s+v not working well. Sometimes it fails to copy the data. Any solutions?

If I try to move between different workbooks using alt+tab and copy values and paste them in the other workbook with alt+e+s+v frequently the data disappears from the clipboard. I've been trying to find a solution to this particular problem online and haven't encounter the solution.

Excel Makro to copy into another program

For my work i need to track what cases i did. Right now i note all the case numbers in an excel file where i also sort them to the categorie they belong. At the end of every week i then have to put in the numbers in our tracking tool with copy and paste (tracking tool isnt on the same desktop i work on so i cant do it directly)
So i thought maybe it would be possible to write a macro in the excel file that does the copy paste for me but i already fail when i want to switch from the excel to the tracking tool
I tried shell activate and windows activate but i only get run time errors
Im grateful for any help even different approches
Please add screenshots and more explaination of the scenario so we could have better insights

EPPlus changes cell interior color

I found something really strange while using EPPlus and I couldn't find the solution anywhere online (I also didn't find anyone with the same problem to be fair). Luckily, after some time, I found out how to fix it and because I couldn't find anything about it, I want to save someone else his/her time and document it here. Note, the past week was my first experience with EPPlus so I'm sorry if this question is very trivial and everyone knew this already.
The Issue
I'm trying to put data into an existing Excel template using EPPlus. One of the sheets of the Excel file looks like this:
Nothing strange about it you would say. However, when I open this Excel file in my code and use EPPlus to add values and save it, it comes out like this:
Of course the numbers in the table are intentional, but how does it suddenly have a purple background!? Also why doesn't it happen to particular cells. There is nothing in the code that does anything with the styling. I only add values to the table.
Another strange thing is that this happened on multiple pc's, but not on all.
The underlying problem
After looking around, I found out that the standard styling suddenly showed the same purple color.
Before
After
I still don't understand why it changes the color, but it does.
Then somewhere on github, someone mentioned that you need to change the code of EPPlus to get rid of this. It mentioned that because the Excel spreadsheet was created in another language than English, it couldn't find the "Normal" style, since it's named "Standaard" in Dutch in this case, and you have to change "Normal" into "Standaard" in the code.
But I just used Nuget to get a package and didn't want to create my own package, and more important: What if I have a spreadsheet next time that is created in the English version?
The Solution
For such a long story, the solution is just to easy: In you workbook, in VBA in the immediate window, type the following code
Thisworkbook.Styles.Add("Normal")
The workbook now has a custom format called "Normal". Since it's likely that your normal format would be just blank, this will show you the proper styling.

Ghost/Phantom Workbooks/sheets appear in VBA Project list alongside legitimate sheets

(edited a day later - see end)
Not sure what's happening here but it's occurring in a few workbooks I'm working with. Over time additional "Phantom" worksheets (or workbooks) appear as shown in the picture. Sheet13, Sheet14, Sheet15 etc are Phantoms and I have no idea how to get rid of them.
What I've tried so far:
1) Searching Google/Stackoverflow no joy but could be a terminology problem
2) Created SUBS to loop through ALL worksheets and workbooks but the only things it finds are the single workbook and the legitimate worksheets.
3) Creating code within one of the phantoms, which is possible. I created a simple SUB on workbook open within Sheet13 to return the name of the sheet or workbook, but no matter what code is there I get
Run Time Error '429':
ActiveX component can't create object
4) Changing properties on the phantoms. The properties for each phantom exactly mirror each other and mirror ThisWorkbook. If I make a change to one, say KeepChangeHistory to False, this is mirrored in ALL phantoms and ThisWorkbook. If I make the change back to True in another phantom, again ALL phantoms and ThisWorkbook are updated.
5) Checked links (greyed out). Tried F5 -> special -> objects "No Objects found".
I've basically tried everything I can think of and searched the internet over the past week before posting this here, as a last resort.
Does anyone have ANY idea what could be causing this (I'm leaning towards some bad object handling somewhere), but also HOW to remove them completely so the only things listed are the actual, real, worksheets?
Thanks for reading.
edit
It affects more than just this workbook (it's happening in 3 different workbooks), it is also getting worse over time. I have saved archived versions of all workbooks. If I go back a month, there are 2 "phantoms", if I go back 2 weeks there are 8 "phantoms" and if I look at one from just last week there are 13 "phantoms". This is one of the reasons I'm assume some poor object handling, likely related to ThisWorkbook is going on. Anyway, I'm going to take Rory's advice and create a new Workbook with NO phantoms and try and figure it out from there. Just want to thank Rory and Mark for taking the time to respond with ideas, it is appreciated.
Well, I guess the simplest answers are the best. What I didn't mention in the question is that each workbook I've worked on that has this problem is uploaded to a 3rd party application, which is, in turn, sent to a second 3rd party application (bespoke apps written by others).
The second application creates 1 or 2 of these "phantoms". I choose to work slightly differently to other developers and I actually use the output from the second application to make changes/fixes, then format that workbook and reupload to application one.
Over time, more and more "phantoms" appear, 1 or 2 per run through this process.
In the end, absolutely nothing to do with Excel, poor code (at least mine!), badly handled objects or anything else.
Thanks again to Rory and Mark for attempting to help. Maybe next time I'll actually start with the mindset of "I'm sure this ISN'T my fault!" and go from there!
I had exactly the same problem. I was reaching the Sheet41111. I used the option Book Inspection in the Information Menu, then I selected remove hidden objects and it luckily worked.
See the image attached, my excel is in Spanish so maybe the option is not really called "Book inspection" in the English version.
Hope it is useful
Pd- Unhide the legitimate sheets because it will delete all hidden sheets. I suggest trying it in a copy of the book. enter image description here enter image description here

how to copy multiple selections from excel to word (manually and/or VBA)

Using Excel/Word 2007 I'm trying to copy multiple selections from Excel to Word. When I paste it into Word it's as if it ignored the break in the ranges and just pastes a range that includes everything I was trying to leave out.
For instance if I intend to copy/paste "A2:D4, A6:D7, A10:D11" what is actually pasted in word is "A2:D11", so it's ignoring the breaks in the selections. I can't seem to find any documentation on this issue anywhere. If someone knows anything I'd really appreciated it. I know I'm selecting the ranges properly because if I copy and paste the multiple ranges within Excel it works like it should.
The actual issue is that I have these actions automated in a macro and I'd really prefer not to loop through the individual ranges because they're stored in a dictionary and it would be just a real hassle. Despite that, it seems weird that I can't even accomplish the task manually.
I've done quite a bit of digging and can't seem to come up with anything. I thought about using the Office clipboard but you can't paste tables as an RTF. It doesn't seem like there are any options when pasting with the office clipboard.
AFAIK it doesn't seem possible and I've tried to exhaust all my normal avenues of knowledge before posting here. If anyone has ever just experienced this it would be comforting to know I'm not alone.
I don't know how to prevent that from happening, but you could potentially work around it by pasting your non-continuous selection into a continuous region in a new, temporary sheet/workbook, then copying the continuous region from the temp sheet/workbook into word.
a bit of a hassle, yes, but it should get the job done.

Resources