Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Saving Document and VB Macros saving with new copy

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
504
0
16
US
All;

I have an interesting problem. When I save a document that contains VB macros, the macros and VB code does not save as well. What can cause this?

Steps Take:

1) Direct copy and save the file under a new name via Windows Explorer

2) Open original document and perform file > save as

Problems with both issues:

When I open either document and then save, I loose the VB and macros. When I initially open the documents the VB and macros are there.

Thanks for the assistance,

Mike
 
HI,

When you SaveAs, do you also SELECT in the SaveAs type... macro enabled workbook (*.xlsm)?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Hi Skip,

Yes I do. (.docm)

Mike
 
Ok so something really strange. If I unlock the word document, which is a form, I can see the code now. It just wont do anything.

Code example:

Code:
Private Sub Add_Doc_Click()

Application.ScreenUpdating = False

If Add_Doc = True Then

Add_Doc_TextBox2 = Add_Doc_TextBox

Else

Add_Doc_TextBox2 = ""

End If

Call TofC_Update

Application.ScreenUpdating = True

End Sub

Mike
 
Your macro could be in Normal modules, a userform or class module or in the ThisDocument code window.

Look in your Project - Normal.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Hi Skip,

The code is not under Normal and is located in:

Project
- Microsoft Word Object
-- ThisDocument

When I close and re-open the file sometimes the code is there and sometimes it is not under ThisDocument

Mike
 
Strange.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
That suggests you have Word configured to block all macros without warning and that:
• you're copying/saving the file to a different folder and the destination folder isn't a trusted one in Word's Trust Centre; or
• the original is defined as a trusted document in Word's Trust Centre, which the copy is not.

Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top