excel ExportAsFixedFormat does not work in .xls when updated to windows 11

Yveske

New Member
Joined
Jul 11, 2024
Messages
9
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi,

I had some VBA code which creates a pdf from an excel file (.xls).
This worked without a problem.
Since yesterday my computer is updated to windows 11 and now this code does not work anymore.
When I open the .xls file, it gives an error on the line with 'ExportAsFixedFormat'.
When I save my file as .xlsx and then run the code, then there is no error?
Does anyone have an idea why this doens't work in my .xls file?
Maybe a setting in windows ?

Thanks
 
I am using Windows 11, and that block of code appears to be working fine for me.
You don't have any hidden sheets, do you? That could cause issues.

Note that you may want to verify that you are create a valid file path and name. You can do that by adding this line of code just before that "ws.ExportAsFixedFormat..." line:
VBA Code:
MsgBox "Filename is: " & spath & sBestand & ".pdf"
This will return to the screen the full file path and name of the PDF file you are trying to create.
Make sure that the path and file names are valid, and that you have rights to create files in that folder.
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi,

when running the code in an excel file with extension '.xls', the result is:
1721112984835.png

When running the code in an excel file with extension '.xlsx', the result is the same:
1721113151538.png

The folder 'Data' exists as you can see below.
1721113026259.png


So 2 times the same file name and location, but the difference is that the file is saved when the code is running from an excel file with extension '.xlsx', but not saved from an excel file with extension '.xls'.
 
Upvote 0
Where is the VBA code stored?
Is it stored in the same workbook as where the data resides?
If so, it should have a "xlsm" or "xlsb" extension, as "xlsx" extensions cannot contain any VBA code.

If it is stored in a separate file, where in your code are you opening this data file?
 
Upvote 0
The VBA code is stored in an add-in, which is loaded into excel.
 
Upvote 0
I don't know. I ran some test of that section of code on both "xls" and "xlsx" files, and both seemed to work just fine for me.
So I cannot recreate your problem.

Are you sure that there isn't any issue with that one file?
It isn't protected, locked, or stored in a location you cannot write to, is it?

Not really sure what else I can do since I cannot recreate the scenario you are describing.
 
Upvote 0
No there is no problem with the file.
I tested even with a new file saved as '.xls' and saved as '.xlsx'.
In the first case, 'xls' file, I receive the error.
In the second case, 'xlsx' file, the pdf is generated.
Strange issue.
Anyway thanks for looking into it.
 
Upvote 0
You are welcome.

Sorry I could not help more, but I cannot see any issue. It could be an environmental or network issue. Not really sure.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top