How to copy data from csv file & paste into powerpoint using vba - vba

I am having problem while copying data from csv file & paste it to power point.
I am successfully doing it while importing excel into power point but having trouble with csv file.
Any suggestion would be very helpful.
Thanks

#Gazal solved this problem by:
Pasting the data into a blank workbook in Excel
Copying it from Excel and pasting it into Powerpoint

Copy the csv file data as we copy excel data
i.e. Take csv file as a workbook.

Related

How to use macro enabled excel file in HP UFT?

I am using below code
import Datatable.ExportSheet path, sourcefile, destinationfile
And I am getting below error
The DataTable.ImportSheet operation failed. invalid file error
Assuming that you are getting an error message while importing a macro enabled Excel into UFT datatable
Answer is, you can't import a macro enabled Excel (xlsm) file into UFT datatable. The reason being, Datatable.ImportSheet accepts only .xls or .xlsx file extensions.
Workaround is, save the xlsm file as Excel 97-2003 Workbook (xls) format using Save As function from Excel. Or save the xlsm file as Excel Workbook (xlsx) format.

Python Openpyxl return a sheet name which doesn't exist

In my excel file, I have only three worksheet: "Slot 14", "Data Display", and "Ctrl Value".
When I use openpyxl to load excel file, it returns other worksheet which doesn't exist: ['Slot 14', 'DETAILNO-14', 'DETAIL-14', 'PNO-14', 'DATA-14', 'Data Display', 'Ctrl Value']
Following is my code
filepath=r'D:\Users\chshiu\Desktop\filename.xlsx'
wb = openpyxl.load_workbook(filepath)
wb.get_sheet_names()
I don't think there is something wrong in my code. I am wondering maybe the problem is from excel file itself? I have VBA code inside the excel file.
More information:
I use Python3 in windows.
Because openpyxl cannot load xls file now so I save my original xls file into xlsx file.
It's possible that your file contains hidden sheets. Older versions of Excel use things called Macrosheets for some of the GUI controls. openpyxl just reports what it finds.

Excel VBA: SaveCopyAs with different file extenstion

I have an Excel file with .xlsb extenstion and use its macros to generate several other Excel sheets based on the contents. The macros work in a way that they change the original Excel file and then use the SaveCopyAs method to save the generated Excel sheets.
The generated Excel sheets should be saved with .xlsx extension and format.
Using the ActiveWorkbook.SaveCopyAs "C:\TEMP\XXXX.XLSX" method is not working for me because while it does change the extension it does NOT change the file format so when a user opens a generated Excel file he receives a warning message (something like "the file extension and format does not match"). The SaveCopyAs method does not have any other arguments.
How can I save the copies of my original .xlsb file with both the extension and format to be changed to .xlsx?
Note: the Workbook.SaveAs method does have a fileformat option, not sure if that helps / relevant.
Based on the hint by Zac, in my case its a better solution to copy the tab with the relevant changes into a freshly created excel file and then save it with the new filename.
ThisWorkbook.Sheets("myTab").Copy
ActiveWorkbook.SaveAs Filename:="c:\temp\xyz.xlsx", FileFormat:=51
ActiveWorkbook.Close
This is actually a lot better solution for me as the end user really need the generated tab only and not the macros or any other data in the orginal excel file.

Save workbook along with vba code

I've created a workbook which contains some macros along with it. My task is to save it including macros so that I'll be able to run them on the saved workbook. When I try to save it in ".xlsm" format--which is a standard format to save vba code--it's getting saved however, I'm unable to open the workbook from the desired saved file. The following window is displayed
" Excel cannot open the file "file.xlsm" because the file format or extension is not valid. Verify that the file is not corrupted and that the file extension matches the format of the file"
Can someone help me with this ? I've tried using ".xls",".xltm" formats as well. But, they don't save the vba code.
Try manually changing the file extension to ".xls" and then open it. If it opens, then do a "save as" in Excel and save it as "macro-enabled" (.xlsm).

Save individual Excel sheets as CSV

I need to parse Excel work sheets. Now I save each individual work sheet as .csv and it works great. I use OpenCSV to parse the files etc. but to create those .csv files are a pain.
What would be the easiest and quickest way to save individual work sheets as .csv in Excel? I am assuming some kind of VBA macro would do the job, but since I am not a VBA programmer I have no idea how to do it. Maybe I can just record a macro somehow?
Very roughly,
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.SaveAs "C:\docs\" & ws.Name & ".csv", xlCSV
Next
This does not include any error coding nor does it make allowances for sheet names that will lead to illegal file names. It all depends on how robust you need the whole thing to be.
As a first answer, here is the code used to save a file to CSV:
ActiveWorkbook.SaveAs "C:\Marthinus.csv", fileformat:=6
More info about SaveAs