Forum Discussion
gseach
Feb 26, 2024Copper Contributor
Permission Denied error when moving a file
Hi all, I'm using Excel 365 MSO (Version 2401 Build 16.0.17231.20236) 64-bit. I have a spreadsheet (let's call it 'Main') that contains a bunch of VBA to do the following. It first imports da...
JKPieterse
Feb 26, 2024Silver Contributor
You are using Powerquery to pull in the data to Excel, that means .NET is involved. perhaps a garbage collection issue? Is the workbook closed which contains the queries, at the point when you are trying to move the file?
gseach
Feb 27, 2024Copper Contributor
Thanks for all your help, JKPieterse.
I found some code on the web that did what I wanted without incurring any errors later on.
'Open the packfile and import its data
Set wb = Workbooks.Open(fil.Path)
Set sht = wb.Sheets(1)
sht.Copy After:=ThisWorkbook.Sheets("Settings")
ThisWorkbook.Sheets(3).Name = "DataImport"
wb.Close False