Access vba copy spreadsheet to new workbook

swell

Member
Local time
Today, 14:53
Joined
Mar 10, 2020
Messages
77
Hi, I have exported data to a spreadsheet to auto populate a pre-formatted spreadsheet in that workbook from my access DB.
This works! This was code I found and modified with some assistance.

I am concerned that the data now relies on the integrity of the 2nd sheet in the workbook.
Therefore I want to copy the formatted spreadsheet of the source workbook copying the data values and formats (without the underlying formulae).

I have found some code on the net that I am attempting to modify for my own purpose.
I am getting an error with this portion of code I added to save and close the workbooks.
Code:
Workbooks(mySourceWB).Close savechanges:=True
    Workbooks(myDestWB).Close savechanges:=True
the error is Run-time error '13'
Type Mismatch
Should I just use
Code:
workbooks.close savechanges:=true
and assume that it has closed both the source and destination workbooks?
 
what is mySourceWB and myDestWB? are they string (the name of the workooks)?
or Object?

if they are objects, just close them without using Workbooks.

mySourceWB.Close savechanges:=True
myDestWB.Close savechanges:=True
 
what is mySourceWB and myDestWB? are they string (the name of the workooks)?
or Object?

if they are objects, just close them without using Workbooks.

mySourceWB.Close savechanges:=True
myDestWB.Close savechanges:=True
Thank you! that fixed that problem.
 

Users who are viewing this thread

Back
Top Bottom