Excel VBA runs significantly slower after saving the page as a pdf - vba

I have a very strange problem in my excel vba program. I have a ton of vba code that executes queries and formats data. Everything works reasonably quickly. However if I save the page as a pdf and then go back to clicking around and executing more queries. Everything takes significantly longer to run. I have to wait for up to 10 seconds for my queries to execute and show me the data. Before saving as pdf this only took a second. Does anyone have any idea what is going on?
Thanks!
I am using excel 2007. I am creating the pdf via VBA but I have also tested by using the save as pdf button in excel and exactly the same thing happens. It only appears to slow down if I save my entire worksheet as pdf. If I select 1 graph and save it as a pdf it does not slow down. the worksheet I am trying to save consists of several comboboxes, buttons, 2 graphs and table

The answer is: don't save as pdf. Ever.
If you want to provide reports in pdf format, 'print' your workbook (or predefined print ranges) to the virtual printer provided by Adobe, which generates usable pdf files.
Keep the workbook as xls, and treat pdf as a presentation format with limited functionality.

Related

Live updating from a .txt file to PowerPoint textbox

Quick note: I have no background/experience with VBA so will need some explanation as to what is going on.
I've wrote a Python script to pull the latest XML data from an IoT sensor (temperature readings) and store it in a text file. I would know like to get this data displaying on a PowerPoint, but this data could change during the PowerPoint, and I would like the PowerPoint slide to be able to update, receiving changes to re-display an updated version of the data.
To summarise: Currently, I have a text file with the data that needs to be read and need a VBA script to read it and place it into a textbox with live updates.
This is what I have found so far:
http://www.pptfaq.com/FAQ00124_Read_in_text_from_an_ascii_file-.htm
The above page shows a VBA script that opens a .txt file and reads it until the EOF. I am not certain how this script would output to a textbox though.
Thanks in advance.

Generate PowerPoint presentations with Excel sheets / charts embedded in it programatically

So what my client wants to accomplish seems pretty simple. We will have PPTX file template with a few Excel sheets embedded in it, and a few charts too.
We have created such template file. We are able to extract it, update excel files that sit in ppt/embedded directory with new ones, and pack it back.
The problem is, the display values of the tables or charts do not update automatically when such file is opened. You have to double click on a spreadsheet table or chart to trigger "edit mode". When you leave it the charts are updated.
We figured that internally, PowerPoint is doing screenshots of tables or charts, and uses it to display presentation. This is probably to allow presentation players that do not come with Excel to correctly render the presentation with embedded sheets.
Is there a way I can programatically update the screenshots of tables/charts? Is there some sort of API from Microsoft that would allow me to do that, like "MS Office API".
Maybe there is some way to have MS office configured/scripted, so I send it a file, it runs a VB script on it and returns updated value? I figured I can actually trigger update to screenshots with VB script. But I don't know if I can orchestrate Office program to do what I want.
Help? :)

Is it possible to export PowerPoint shape in custom format and then import it back to powerpoint?

Have a wierd request.
I have a powerpoint add-in which allows to quickly insert shapes and graphics (also shapes) to the presentation.
It works ok, but the obvious problem I see now is performance, as I store shapes in seperate pptx file.
There are 2 ways I approached working with the shape insertion:
1. Store everything in one presentation and keep it open in the background. The downside is that it makes powerpoint really slow, because the file is just too big (more than 8 mb)
2. Store every slide as a seperate file and open it as needed. This just makes the programm slower, than usual, but works fine. The key downside is that PowerPoint stores every open file in the register and you can not use "recent file" features of the PPT.
What I hoped was possible to do is to save each shape from powerpoint that I heed as seperate file and insert them individually, which would significantly increase the speed of my add-in. However, the only thing I could do is just expoer shape as EMF, which is unacceptable for me.
So my question is: is it possible to export PowerPoint shape in custom format and then import it back to powerpoint? I am using VB.net and VS 2013
Team foundation addin for VS 2013 does something similar, but I need to understant the code and logic behind it and have no idea for now.
You help is HIGHLY appreciated.
Iakov

Save excel as pdf changing its orientation to horizontal

I have an excel sheet with too many columns, so when I save it as a PDF the file its in too many pages and its not easy to read . I need to save the sheet as pdf but before I want to change its orientation to horizontal so I can read the pdf with no problem. Is the same you can do when you print but I want it when I save an excel file as pdf.
Is there any option I can choose?
I dont mind if someone gives me a code for a macro using my selection as an object.
Under the "Page Layout" tab, click the "Orientation" option and then select "Landscape."
Then create your PDF as usual.
You can save Excel files in PDF, even without using Excel. I use a program Universal Document Converter (http://www.print-driver.com/how-to/save-excel-as-pdf). This program allows you to quickly and easily create print-ready PDF-files on the basis of the original spreadsheets Excel.

VBA vs VSTO for excel to powerpoint

I'm currently considering a number of options for copying an excel sheet into a powerpoint presentation.
Using VBA select a excel sheet, copy the range and place it into a newly created powerpoint slide as an image.
I create excel automated html of a sheet, once that html is saved(initially), i create an image off of the html.
Using VSTO, i open Excel copy each object and paste it into a new powerpoint slide, using the clipboard(or another copy method).
These operations will be called frequently, by many different users - all the actual operation occurs on a single server.
What would the pros and cons of each approach be? Are there any prefered or better optimized techniques available?
Option 1:
Pro:
Speed
Contra:
The inserted Data can't be copied, altered, viewed within excel etc.
Option 3:
A couple of years ago I wrote a similar VBA-Procedure that created a >1000 Slides Presentation from an Excel Sheet. The method was called from Excel and went AFAIR like this(pseudo-code):
newSlide = PowerPoint.AddSlide
embeddedSheet = newSlide.Add OLEObject(Excel-Sheet)
embeddedSheet.Range(..., ...) = srcSheet.Range(..., ...)
someFormating(embeddedSheet)
createPieChart(embeddedSheet.Range(..,...))
resize(embeddedSheet)
embeddedSheet.Save
embeddedSheet.Close
Pro / Contra based on my experience with the method above.
Pro:
The Sheet is embedded in PowerPoint
you can alter the Data and run Macros on it.
you do not need to keep the original Excel sheet.
Contra:
The Output-File is bigger
The Process uses a lot of RAM.
The Process takes relatively long. AFAIR 1k Slides took about 10 Minutes on the computer in my office. Creating the OleObject took the majority of the time.