Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Step macro vs run

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Franks - 30 Mar 2005 18:55 GMT
When I step through the code in my macro it works perfectly, but not when I
run it.
I've noticed that some macros do not work correctly when they are run (F5).
For example this macro is supposed to copy all the items in the file
properties dialog from one document to another.
Sub XferProps()
Dim strTitle As String, strAuthor As String, strManager As String
Dim strSubject As String, strCompany As String, strCategory As String
Dim strKeywords As String, strComments As String
   strTitle = ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle)
   strSubject = ActiveDocument.BuiltInDocumentProperties(wdPropertySubject)
   strAuthor = ActiveDocument.BuiltInDocumentProperties(wdPropertyAuthor)
   strManager = ActiveDocument.BuiltInDocumentProperties(wdPropertyManager)
   strCompany = ActiveDocument.BuiltInDocumentProperties(wdPropertyCompany)
   strCategory = ActiveDocument.BuiltInDocumentProperties(wdPropertyCategory)
   strKeywords = ActiveDocument.BuiltInDocumentProperties(wdPropertyKeywords)
   strComments = ActiveDocument.BuiltInDocumentProperties(wdPropertyComments)
   ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

   ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) = strTitle
   ActiveDocument.BuiltInDocumentProperties(wdPropertySubject) = strSubject
   ActiveDocument.BuiltInDocumentProperties(wdPropertyAuthor) = strAuthor
   ActiveDocument.BuiltInDocumentProperties(wdPropertyManager) = strManager
   ActiveDocument.BuiltInDocumentProperties(wdPropertyCompany) = strCompany
   ActiveDocument.BuiltInDocumentProperties(wdPropertyCategory) = strCategory
   ActiveDocument.BuiltInDocumentProperties(wdPropertyKeywords) = strKeywords
   ActiveDocument.BuiltInDocumentProperties(wdPropertyComments) = strComments
End Sub

When I run it Author, Manager and Company aren't copied.

This is not the first time I've had similar problems with VBA.
Any suggestions?
Thanks
Signature

Steve Franks

Howard Kaikow - 30 Mar 2005 21:13 GMT
error handling can be different between design and run modes,
verify that all properties exist.
Signature

http://www.standards.com/; See Howard Kaikow's web site.

> When I step through the code in my macro it works perfectly, but not when I
> run it.
[quoted text clipped - 30 lines]
> Any suggestions?
> Thanks
Steve Franks - 31 Mar 2005 12:27 GMT
They do.

> error handling can be different between design and run modes,
> verify that all properties exist.
[quoted text clipped - 46 lines]
> > Any suggestions?
> > Thanks
Howard Kaikow - 31 Mar 2005 21:30 GMT
i would suggest puting a debug.print statement after each statement that
retrieves a propety to print tge value retrieved.

then use  Run and also step by step to see what differs.

Signature

http://www.standards.com/; See Howard Kaikow's web site.

> They do.
>
[quoted text clipped - 48 lines]
> > > Any suggestions?
> > > Thanks
Steve Franks - 06 Apr 2005 13:39 GMT
I've solved the mystery.
There's nothing wrong with the code.
Word deleted the data, because the option to 'remove personal data on save'
had been set by the Remove Hidden Data tool.
Steve Franks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.