I have a VBScript and a method that inserts a picture from a .jpeg file into and excel sheet. I will like for the picture to save to the excel sheet so that when the excel file is sent to another person, they can view the picture.
I have noticed that picture links to the local folder on my computer from which i copied it.
Is there a way to save the inserted picture to be part of the Excel document?
This is my method
set attachment = .Pictures.Insert(path)
The Shapes.AddPicture Method has a parameter to specify whether
To save the picture with the document.
This solution to the same problem replaces .Insert with .AddPictured successfully (German, sorry).
Related
I create reports in powerpoint where the graphs/tables within the report are created from underlying excel sheets embedded as objects within the powerpoint. When I open these files, each file has the exact same name, which is the name of the powerpoint presentation/file. Is there a way to change the name of each underlying excel object to something unique?
I am doing this so that I can copy data from subscription reports to the powerpoint presentation via python.
Thank you!
The window title is not the file name. Embedded Excel objects are renamed to "Microsoft_Excel_Worksheet.xlsx", "Microsoft_Excel_Worksheet1.xlsx", etc. and are stored in the ppt/embeddings folder in the XML. It's not possible to change this behavior.
However, if you link the Excel rather than embed, the original file name is retained and that file name displays on the top of the Excel window. The path and file name are stored in PowerPoint.
I've managed to copy the cell from the embedded excel sheet and use Home/Paste special/Paste link/Unformatted text in the word document body. If I change the cell value in the embedded sheet, the linked field in the document is updated accordingly.
The problem is that, once I close and reopen the word document, the link cannot be updated, it says "word is unable to create a link to the object you specified". If I open the 'edit links to files' pane, the excel worksheet object seems to receive a new name every time the word document is reopened excel object name
Do you see a workaround in this situation?
Thanks in advance for your help.
Problem solved! The document was originally created in a previous version of Word, with the excel object contained inside a table. Probably the table and excel objects were not properly migrated when saving the file to the 2013 .docx format. The solution was to simply delete the table row where the excel was contained, reinsert the row, embed the worksheet and recreate the link from the excel to the document body. It seems that the table and excel object were somehow reinitialized and the link is updating as it should.
I am try to make my first mail merge macro but I donĀ“t know how.
Can somebody help me? I need to generate an individual document from excel to word document, save it with the name of value in cell "A2" and then close word. Is it possible?
The word template path is: C:\Users\admin\Desktop\New folder (2)\all1.docx
The excel file path is: C:\Users\admin\Desktop\New folder (2)\source.xlsm
Source to mail merge is sheet Mailmerge
if i understand it correctly, you would like to save the worksheet to a MS word file? If yes, you could just use the saveAs function in excel-vba. you could record a macro then save the worksheet and viola, you now have the code :) just edit it..
I have a .csv file which I can export and from which I need to copy data into word.
I know how to get the relevant data from Excel and format my .csv file with VBA, however I don't know how to get my data from that Excel file to Word.
Basically this is how a line of my formatted .csv file looks (I Got rid of all the info I don't need).
For clarification: 1st long nr. is personnel 2nd one is token.
And I need to fill that info into the following table in word (Not everything gets filled in).
And one extra thing, depending on the extention of the email address #mc or #lmc, I need a different file opened (Different languages). How would I best do that?
Possible algorithm:
In your Excel document, develop a VBA macro that
Copy data/elements from Excel document
Open your word document
Paste excel data to word document (to the places you want)
Save word document
Close word document
Here is some code for inspiration of how to do that.
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();