View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
George Nicholson George Nicholson is offline
external usenet poster
 
Posts: 149
Default Removing VBA from a workbook

Lots of possible solutions. Here is one possibility:

Consider:
- Select entire data entry worksheet/UsedRange).Copy
- create a new workbook
- paste copied values into new book
- paste copied formats over data you just pasted
- Save & email new book
- ? remove entries from data entry book & resave
- ? or simply close data entry book without saving (i.e., in its original
state)

This would give you your formatted data (no formulas or code) in a clean
workbook.
The following code is a bare-bones *functioning* version of the 1st 4 steps
above (assumes sheet with data is Active when called).

HTH

Sub CopyValuesAndFormatsOfSheetToNewWorkbook()

ActiveSheet.Cells.Copy

Workbooks.Add
'Note: NewWorkbook becomes the ActiveWorkbook automatically
'So ActiveSheet now points to New workbook as well.
'If you need/want to set references, now is the time to set them:
'(Optional) Set wkbNew=ActiveWorkbook

ActiveSheet.Cells.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
ActiveSheet.Cells.PasteSpecial _
Paste:=xlPasteFormats, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
End Sub



"DawnTreader" wrote in message
...
Hello all

well, what started out as a little project has turned into a major one.

i work in a department of a company where we have technicians who need to
send in a time card that records hours that they are doing service outside
of
the manufacturing and production shop that they work in when not doing
service. up to this time we have had at least one problem every week that
time cards are submitted with either the actual information in the time
card,
or who it is submitted to or the file name not conforming to the way we
want
it submitted.

so i have been working on automating the submission of time cards. i have
everything working exactly the way i want it. when the workbook opens all
the
toolbars are removed, a dialog pops up and asks for thier name, employee
number, and the date of the sunday at the beginning of the week they are
submitting for. i even used combo boxes for the date entry.

then i have a button which saves the file into a specific folder in the
users my documents, that folder is created if it isnt there, then it
creates
an email with the workbook as an attachment and emails it to a specific
email
address, adds the toolbars back, and finally closes excel and the
workbook.
it is a pretty piece of automation if i do say so myself. :)

except that when i tried to send it from home to myself at work, to test
whether it will work from outside the office, it failed.

"Your message was rejected by (our server) for the following reason:
MS-Office file containing VBA macros found inside of the email The
following
recipients did not receive this message: We hope this information is
helpful."

ARRGH! so my first thought is to save the workbook, then save it again
stripped of all VBA as a separate file, then to email the stripped file,
then
to delete the stripped file and then finish as before. is that the best
solution?

i was also thinking of having the code not put an extention on the file,
email it and then i can correct the extention when i recieve it. is that
going to work?

another thought is, would the system i have set up work as an add in that
causes a workbook to be sent that doesnt have VBA in it?

as i have worked on this, i have written it in other places. i need this
to
be as dummy proof as possible. any suggestions or ideas or code posted
would
be greatly appreciated.