Can VBA open a document embedded in an Excel workbook - excel

If I want to open a .oft document from Excel with VBA, I normally indicate the folder path to the .oft document in VBA.
Is it possible to attach/emmbed this .oft in the Excel file and indicate VBA to open it from the Excel file instead of indicating a folder path??
Thanks!

Here's a code sample for VB.NET from Word to give you an idea of the code constructs you need to use. Note that the Excel VBA model and Word VBA model differ and sometimes use different function/method names (I don't know for sure but this sometimes happens). Just search the guides at Microsoft.
For Each shp As InlineShape In wordDoc.Content.InlineShapes
If shp.Type = WdInlineShapeType.wdInlineShapeEmbeddedOLEObject Then
If shp.OLEFormat.ProgID.Contains("Word") Then
shp.open() ' Open the embedded Word document
end if
end if
next

Related

Create PDF bookmarks Within Excel Workbook

I'm attempting to build a monthly process that converts an excel file to a PDF with bookmarks for each respective sheet. I'm not seeing a method to successfully create PDF bookmarks from within the Excel workbook. Can this be accomplished without third-party software?
What I've tried:
Using Header 1 for a cell as well as an entire row.
Putting Excel Book Mark within the file using a hyperlink reference.
Adding named range.
OneDrive flow Convert File
Adding a Header.
Reviewed some VBA Ref libraries hoping to find an object.bookmark type approach.
Unfortunately, all attempts have resulted in a PDF file with no bookmarks.
Is there a method to create PDF Bookmarks from Excel? Possibly a VBA ref library that I am unaware of or some front-end trick? Unfortunately, I'm stuck working only with Microsoft tools. Adobe's Excel Add-On does exactly what I'm trying to achieve.

VBA Excel copying the Visio current worksheet drawing and paste in Excel worksheet

I would like to copy the stuff from Visio to excel, if that possible.
I found some hint here:
Copying a visio page and pasting it in excel as an image
and tried to use in my code:
Sub Visio()
vsoPage.CreateSelection(visSelTypeAll).Copy
CIwb.Worksheets("Cables1").Paste
End Sub
but I am getting error 424 - object required.
Debugger points the following line:
vsoPage.CreateSelection(visSelTypeAll).Copy
How can I copy the current Visio worksheet to my current Excel sheet?
Take a deep look at the answer you refer in your question: Copying a visio page and pasting it in excel as an image
There's a note:
'Assuming your page object is named vsoPage 'This embeds the visio
drawing
So, you have to use a name of Visio page, which you want to copy.
Another requirement is to use proper Excel workbook and worksheet. So, do not use dummy-copy of code. Instead of it, try to understand what it does and change it to your needs.
Note: code presented in original question is placed in Excel! If you want to run it from Visio, you need to:
1) create an instance of MS Excel
2) open existing Excel workbook or create new one
3) copy Visio page
4) close Excel workbook
5) close an instance of MS Excel application
Good luck!

open an specific excel sheet from powerpoint using object

Im trying to open a specific excel sheet from my PPt-slide using "insert>>object".
So my Excel Workbook is calling " mape1", and in this Workbook here are many sheets, and I want to open a specific one called "sheet1".
I gave the following pfad in the "object"
As Example
C:\Users\me\Desktop\mappe1\sheet1.xls
But it doesn't work
what am I missing?
Thank you for your help
Check out this support article from Microsoft I've linked below. It says by using the insert method you will bring in "all data from the active, top spreadsheet in the linked Excel workbook."
I suggest copy and pasting the selection you want into PowerPoint as is described here:
https://support.office.com/en-us/article/Import-data-from-Excel-into-PowerPoint-3ec295e9-1bfd-47ff-8d7d-8b838caef853#__toc241650191

Use SSIS to populate Excel workbook generated using OOXML

We are trying to generate MS Excel workbook using OOXML and populate data using SSIS.
We are able to generate Workbook and sheets, also able to create columns and insert data in the Header cell. We can also populate data using SSIS.
But the Sheet (DocumentFormat.OpenXml.Spreadsheet.Sheet) and all cells (DocumentFormat.OpenXml.Spreadsheet.Cell) becomes OpenXmlUnknownElement. So we are not able to read sheet / cell using following code: Sheet sheet = workbookPart.Workbook.Descendants<Sheet>().Where(s => s.Name == "Sheet1").SingleOrDefault<Sheet>();
We are able to read the same file if we first open it using MS Excel and save. Does anyone know how to resolve this?
You probably forgot to give your sheet a name. You can see this by using
Sheet sheet = workbookPart.Workbook.Descendants<Sheet>().FirstOrDefault
and you'll see that your sheet name is either undefined or garbage text.
If that does not help. Create a simple document in code save it in OOXML and open it in a xml viewer. then make a copy open it in Excel and save it and see the difference in xml. That is often a good start seeing what excel has added by default to the document.
Excel is very tolerant of things that you have done wrong when creating the document in code, and magically fix them when you open the document again.
A bad hack would be using interop to open the document saving it again in code. wich would fix everything for you.
Workbook wrkbk = app.Workbooks.Open(#"c:\del.xls");
wrkbk.Save();
wrkbk.Close();

Creating a new pdf document using AcroEXch in VBScript

I am looking to automate the conversion of an excel sheet into a pdf document (I do not want to manually print the report generated in excel as a pdf document every morning). For now, I would like to create a button in excel that will run the macro to automatically generate the pdf document, but this button will eventually not be used.
Im also new to VB, but have read up on the AcroEXch SDK. Seems like I should be using AcroEXch.PDDoc.Create, but this is not quite right (because I cannot specify an input file to be printed/created as a new pdf document).
Any ideas on how I can create a brand new pdf file? Thanks in advance.
I think i found the answer. Here is one solution someone at work suggested (if anyone finds it useful, then great).
There is no available method in the AcroEXch class (or set of methods that I know of) to convert a non-pdf file to a pdf file. Instead, you have to use the pdf Distiller to first convert the file to postscript and then you can write to pdf, using the PDFDistiller class. Here's a snippet of the code:
'1. open excel being converted to pdf:
xlReport.activate
xlReport.range("a1").select
dim PdfFilePath
PdfFilePath = ""
dim PsFilePath
PsFilePath = ""
'2. Print Excel file to postscript file
xlBook.activesheet.PrintOut , , 1, , "Adobe PDF on Ne01:" ,TRUE, , PsFilePath
Dim oDistiller
Set oDistiller = CreateObject("PDFDistiller.PDFDistiller.1")
oDistiller.FileToPDF sPsFilePath, sPdfFilePath, ""
' Close Excel - do not save.
'COMMENTED OUT BELOW 3 LINES FOR DEBUG
xlApp.displayalerts=false
xlApp.quit
set xlApp=nothing
I don't know exactly what your circumstance is and what tools you have access to, but reading your description, it sounds like you simply want to have an Excel file converted for you with a click.
It would be helpful if you had posted whether you have Adobo Acrobat Professional, latest version of Excel, or other converters that are available on the market.
If you have Acrobat Pro installed, your office apps (word, excel, outlook, etc) should already have a "Convert to PDF" button in the toolbars, in combination with Excel command line argument it shouldn't be too hard to cook up a Windows Scheduled Task that periodically convert excel files for you.
Have you considered CuteFTP or PDFCreator, both are free. I have sucessfully used PDFCreator with VBA and I have heard that CuteFTP is good.

Resources