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.
Related
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.
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.
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.
I am trying to open a file in VBA in Excel 2010 and the code looks like this:
Workbooks.Open Filename:=Folder & FileName
When I execute the code in Excel 2010, it gives me this error:
Can't execute the code in break mode
The file I am opening is of format Excel-2003 format. Is it because of this? I have searched in Google and most suggest it is because of Select statement but I am not using one.
Need some guidance on this.
Workbooks.open runs the workbook_open macro in the workbook it opens. If macros are not enabled for the new workbook, it stops.
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).