S
Steve Franks
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
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