Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Copy workbook without Macros

I'm having problems copying an excel workbook the way I want to.

I currently have a MasterCopy.xls with data on Sheet1 and all my
macros imported. I need to create a new workbook (I called it Junk
Test.xls) and copy the first sheet of MasterCopy.xls onto
JunkTest.xls. However, I don't want the new Junk test workbook to
have any of the VBA macro stuff in it. I can't figure out how to do
that. Here's a basic look at what I have:

Private Sub Workbook_Open()
Dim sDest As String
sDest = "C:\Documents and Settings\rb012653\Desktop"
Data_Mover.SaveCopy sDest
End Sub

~~~In my Data_Mover Module~~~~~
Public Sub SaveCopy(sDest As String)
Dim NewWB As Workbook
Set NewWB = Workbooks.Add(sDest & "\Junk Test.xls")
'I've tried lots of copy commands here without any luck.
End Sub

Whenever I try and open the new JunkTest.xls file I also get the
following error:
Runtime error '1004': Cannot access 'JunkTest.xls.' This is my first
time posting, so I appologize if it is in another thread. I've
searched all over and couldn't find anything to help me figure this
one out.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Copy workbook without Macros

Your code is attempting to use sDest & "\Junk Test.xls" as template for a
newly created workbook. When call Add, if you pass parameter, it must the
name of an existing file that is used as a "template" (in the generic sense,
not necessarily in the "xlt" sense) for the newly create workbook. The
parameter is NOT the name of the file as which the newly create workbook
will be saved. Since sDest & "\Junk Test.xls" doesn't exist, Add blows up
with a file not found problem.

Instead, do something like

Set NewWB = Workbook.Add() ' no parameter
NewWB.SaveAs sDest & "\Junk Test.xls" ' save to disk

See www.cpearson.com/excel/vbe.htm for details and example code about how to
remove all existing VBA code from a workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Robert" wrote in message
oups.com...
I'm having problems copying an excel workbook the way I want to.

I currently have a MasterCopy.xls with data on Sheet1 and all my
macros imported. I need to create a new workbook (I called it Junk
Test.xls) and copy the first sheet of MasterCopy.xls onto
JunkTest.xls. However, I don't want the new Junk test workbook to
have any of the VBA macro stuff in it. I can't figure out how to do
that. Here's a basic look at what I have:

Private Sub Workbook_Open()
Dim sDest As String
sDest = "C:\Documents and Settings\rb012653\Desktop"
Data_Mover.SaveCopy sDest
End Sub

~~~In my Data_Mover Module~~~~~
Public Sub SaveCopy(sDest As String)
Dim NewWB As Workbook
Set NewWB = Workbooks.Add(sDest & "\Junk Test.xls")
'I've tried lots of copy commands here without any luck.
End Sub

Whenever I try and open the new JunkTest.xls file I also get the
following error:
Runtime error '1004': Cannot access 'JunkTest.xls.' This is my first
time posting, so I appologize if it is in another thread. I've
searched all over and couldn't find anything to help me figure this
one out.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Delete Another WorkBook Macros using Macros.. Possible? ddiicc Excel Programming 7 July 24th 05 01:54 PM
How to copy a workbook so the buttons run the macros? - Excel Discussion (Misc queries) 4 May 15th 05 11:24 PM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM
Open workbook-macros enabled, opening another with macros George J Excel Programming 5 September 17th 04 02:07 PM
Copy Macros and VB code from one workbook to another Dawn[_2_] Excel Programming 1 December 2nd 03 11:03 PM


All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"