Hi,
I have followed this forum for a while and found many great solutions to expand my VBA experience. However, I cannot find any solution to the following situation.
I have a macro that downloads a .xlsx file and copy the worksheet to the users activeworkbook. If the user is working in an old file, e.g. in .xls, the function needs to copy all content of the downloaded sheet into a new sheet on the activeworkbook.
To test the filetype I use
This works perfectly, except for when the workbook is new and has never been saved. In this situation, the user (internal use) will be working in a .xlsx file, so the function should just copy the sheet directly.
But how do I test whether the file has ever been saved? The above code results in an error when the workbook has never been saved, maybe this can be utilized instead of a seperate if/then test?
I have tried the following without luck:
I have followed this forum for a while and found many great solutions to expand my VBA experience. However, I cannot find any solution to the following situation.
I have a macro that downloads a .xlsx file and copy the worksheet to the users activeworkbook. If the user is working in an old file, e.g. in .xls, the function needs to copy all content of the downloaded sheet into a new sheet on the activeworkbook.
To test the filetype I use
Code:
If Not wb1.FileFormat = xlExcel12 Then
This works perfectly, except for when the workbook is new and has never been saved. In this situation, the user (internal use) will be working in a .xlsx file, so the function should just copy the sheet directly.
But how do I test whether the file has ever been saved? The above code results in an error when the workbook has never been saved, maybe this can be utilized instead of a seperate if/then test?
I have tried the following without luck:
Code:
If Not wb1.Path = "" Then