Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Dynamic reference to Word

Hello,
With the help of RB Smissaert, I wrote a VBA proc which set a ref on Word
before the main macro, then another which remove this ref.
I tried to adapt this macro in a MS Project module:

Sub BuildWordReference()
Dim Ref As String
Ref = "{00020905-0000-0000-C000-000000000046}"
ActiveProject.VBProject.References.AddFromGuid Ref, 0, 0
End Sub

The macro above worked 5 times, but doesn't work anymore ... ;-(
Sometimes, I get the error message : "runtime error '32813' Module name,
project or object library already used"
The second macro, which is supposed to remove the ref, *never* worked ;-(((
(No error message)

Sub RemoveWordReference()
RemoveReference "Word" 'Call
End Sub

Sub RemoveReference(strReference As String)
On Error GoTo ERROROUT
Dim R As Object
For Each R In ActiveProject.VBProject.References
If R.Name = strReference Then
ActiveProject.VBProject.References.Remove R
Exit Sub
End If
Next
ERROROUT:
On Error GoTo 0
End Sub

Could you help me? Thanks ahead!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dynamic reference to Word

Assuming the code is being run from the workbook containing the reference or
that will contain the reference,
Maybe using ActiveProject would be a crap shoot as to what the activeproject
is.

Thisworkbook.VBProject.References

might be a better reference.

Also, why not use the GUID to identify it:

Sub RemoveWordReference()
Dim Ref as String
Ref = "{00020905-0000-0000-C000-000000000046}"
RemoveReference Ref
End Sub

Sub RemoveReference(strReference As String)
On Error GoTo ERROROUT
Dim R As Object
For Each R In ThisWorkbook.VBProject.References
If R.Guid = strReference Then
ThisWorkbook.VBProject.References.Remove R
End If
Next
ERROROUT:
On Error GoTo 0
End Sub

If you run RemoveWordReference from this workbook, maybe it will help your
problem.

--
Regards,
Tom Ogilvy

"Newbie" wrote in message
...
Hello,
With the help of RB Smissaert, I wrote a VBA proc which set a ref on Word
before the main macro, then another which remove this ref.
I tried to adapt this macro in a MS Project module:

Sub BuildWordReference()
Dim Ref As String
Ref = "{00020905-0000-0000-C000-000000000046}"
ActiveProject.VBProject.References.AddFromGuid Ref, 0, 0
End Sub

The macro above worked 5 times, but doesn't work anymore ... ;-(
Sometimes, I get the error message : "runtime error '32813' Module name,
project or object library already used"
The second macro, which is supposed to remove the ref, *never* worked

;-(((
(No error message)

Sub RemoveWordReference()
RemoveReference "Word" 'Call
End Sub

Sub RemoveReference(strReference As String)
On Error GoTo ERROROUT
Dim R As Object
For Each R In ActiveProject.VBProject.References
If R.Name = strReference Then
ActiveProject.VBProject.References.Remove R
Exit Sub
End If
Next
ERROROUT:
On Error GoTo 0
End Sub

Could you help me? Thanks ahead!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Dynamic reference to Word

Thanks a lot Tom!
The trick was that I used ActiveProject instead of ThisProject. Now that
works!
Thanks again

Newbie

"Tom Ogilvy" a écrit dans le message de
...
Assuming the code is being run from the workbook containing the reference

or
that will contain the reference,
Maybe using ActiveProject would be a crap shoot as to what the

activeproject
is.

Thisworkbook.VBProject.References

might be a better reference.

Also, why not use the GUID to identify it:

Sub RemoveWordReference()
Dim Ref as String
Ref = "{00020905-0000-0000-C000-000000000046}"
RemoveReference Ref
End Sub

Sub RemoveReference(strReference As String)
On Error GoTo ERROROUT
Dim R As Object
For Each R In ThisWorkbook.VBProject.References
If R.Guid = strReference Then
ThisWorkbook.VBProject.References.Remove R
End If
Next
ERROROUT:
On Error GoTo 0
End Sub

If you run RemoveWordReference from this workbook, maybe it will help your
problem.

--
Regards,
Tom Ogilvy

"Newbie" wrote in message
...
Hello,
With the help of RB Smissaert, I wrote a VBA proc which set a ref on

Word
before the main macro, then another which remove this ref.
I tried to adapt this macro in a MS Project module:

Sub BuildWordReference()
Dim Ref As String
Ref = "{00020905-0000-0000-C000-000000000046}"
ActiveProject.VBProject.References.AddFromGuid Ref, 0, 0
End Sub

The macro above worked 5 times, but doesn't work anymore ... ;-(
Sometimes, I get the error message : "runtime error '32813' Module name,
project or object library already used"
The second macro, which is supposed to remove the ref, *never* worked

;-(((
(No error message)

Sub RemoveWordReference()
RemoveReference "Word" 'Call
End Sub

Sub RemoveReference(strReference As String)
On Error GoTo ERROROUT
Dim R As Object
For Each R In ActiveProject.VBProject.References
If R.Name = strReference Then
ActiveProject.VBProject.References.Remove R
Exit Sub
End If
Next
ERROROUT:
On Error GoTo 0
End Sub

Could you help me? Thanks ahead!






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Dynamic reference to Word

Now, the Word references are working fine, but I can't use anymore the Step
by Step [F8] : I get the message:
"Impossible to enter in Stop Mode now"
Why? How can I bypass this trick?
Thanks

"Newbie" a écrit dans le message de
...
Thanks a lot Tom!
The trick was that I used ActiveProject instead of ThisProject. Now that
works!
Thanks again

Newbie

"Tom Ogilvy" a écrit dans le message de
...
Assuming the code is being run from the workbook containing the

reference
or
that will contain the reference,
Maybe using ActiveProject would be a crap shoot as to what the

activeproject
is.

Thisworkbook.VBProject.References

might be a better reference.

Also, why not use the GUID to identify it:

Sub RemoveWordReference()
Dim Ref as String
Ref = "{00020905-0000-0000-C000-000000000046}"
RemoveReference Ref
End Sub

Sub RemoveReference(strReference As String)
On Error GoTo ERROROUT
Dim R As Object
For Each R In ThisWorkbook.VBProject.References
If R.Guid = strReference Then
ThisWorkbook.VBProject.References.Remove R
End If
Next
ERROROUT:
On Error GoTo 0
End Sub

If you run RemoveWordReference from this workbook, maybe it will help

your
problem.

--
Regards,
Tom Ogilvy

"Newbie" wrote in message
...
Hello,
With the help of RB Smissaert, I wrote a VBA proc which set a ref on

Word
before the main macro, then another which remove this ref.
I tried to adapt this macro in a MS Project module:

Sub BuildWordReference()
Dim Ref As String
Ref = "{00020905-0000-0000-C000-000000000046}"
ActiveProject.VBProject.References.AddFromGuid Ref, 0, 0
End Sub

The macro above worked 5 times, but doesn't work anymore ... ;-(
Sometimes, I get the error message : "runtime error '32813' Module

name,
project or object library already used"
The second macro, which is supposed to remove the ref, *never* worked

;-(((
(No error message)

Sub RemoveWordReference()
RemoveReference "Word" 'Call
End Sub

Sub RemoveReference(strReference As String)
On Error GoTo ERROROUT
Dim R As Object
For Each R In ActiveProject.VBProject.References
If R.Name = strReference Then
ActiveProject.VBProject.References.Remove R
Exit Sub
End If
Next
ERROROUT:
On Error GoTo 0
End Sub

Could you help me? Thanks ahead!








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
Dynamic Reference Tyler.C.Brown New Users to Excel 7 July 24th 09 11:58 PM
Dynamic reference of word doc in excel tims Excel Discussion (Misc queries) 1 January 24th 09 12:36 PM
How do i set up a 3d reference where one cell reference is dynamic SmilingSteve Excel Discussion (Misc queries) 15 March 14th 08 05:05 AM
Dynamic reference to another tab name Angus Excel Worksheet Functions 5 February 9th 07 05:41 PM
Dynamic References to Word? Newbie Excel Programming 15 April 9th 06 10:28 AM


All times are GMT +1. The time now is 09:58 PM.

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"