Empty Excel file for any Macro from SW

Hello

I take the liberty of asking you for a hand regarding a very annoying problem on which I am stuck.

I'm trying to export values from SolidWorks using a macro, and the macro runs correctly, Excel opens correctly (names the file correctly), and there. No data inside the Excel file! And this regardless of the macros I use (I tried with several functional macros found on the net to be sure that it was not related to the macro). But I've been working on a new workstation recently, so it must be coming from some software setup.

 

My software configuration: Solidworks  2017 / Excel Office365

Summary: Running the macro from SW (Export Custom Properties to Excel.swp for example) / Excel opens and creates a "Properties Details" file / The macro ends with no error displayed / No data in the file in the file

Any ideas where the problem could come from?

Thanks in advance,

François Cavin

 

 

 

 

Hello

Post your code, so we can help you.

2 Likes

Hello

Here's an example of a macro with which I have my excel file completely empty.

(as a reminder it happens to me with all the macros I've tried)

Have a nice day

French


export_custom_properties_to_excel.swp_.zip

Hello

The error comes from this line:

Set xlWs = xlWb.Worksheets("Sheet1")

It is used to retrieve the sheet named "Sheet1" in the workbook. However, there is no "Sheet1" sheet since in French the default name is "Feuil1".

So I advise you to modify the line as follows:

Set xlWs = xlWb.Worksheets(1)

This retrieves the first sheet of the workbook, whatever it is called.

Your macro then works.

To see your problem, I ran the macro line by line at the [F8] key. This allows you to see the details and to see the variables evolved. In this case, the variable "xlWs" remained empty.

Another piece of advice, avoid the line:

On Error Resume Next

This allows errors to be displayed.

2 Likes

Hello

Thank you very much for your answer, that was indeed the problem.

And also thank you for your advice.

Have a nice day

Francis