OLE Object Set Variable Source Doc

GemaDilemma

New member
Local time
Today, 06:15
Joined
Aug 19, 2013
Messages
2
I have a problem that has stumped me for the last day.

I have a GetUserName Api which extracts the name of the current user, it works perfectly.

I also have an unbound OLE Object that is being controlled on form load by this.


With Me.OLE1
.Class = "Excel.Sheet"
.OLETypeAllowed = acOLELinked
.SourceDoc = "C:\Users\" & GetUserName & "\Desktop\Database\Excel Files\Bulk Updating.xlsm"
.SourceItem = "R1C1:R5C5"
.Action = acOLECreateLink
.SizeMode = acOLESizeClip
End With

When I run the code I get Runtime Error 2101 on Line 4.

When I set Line 4 to Jblogs instead of my get user function it works fine.

Any Help?

Gema
 
Last edited:
have you tried debugging it to see if there is a value returned by GetUserName

David
 
try this to see if your GetUserName is returning a value

Code:
Dim userName as String
 
userName = GetUserName
 
With Me.OLE1 
.Class = "Excel.Sheet"
.OLETypeAllowed = acOLELinked 
.SourceDoc = "C:\Users\" & userName & "\Desktop\Database\Excel Files\Bulk Updating.xlsm"
.SourceItem = "R1C1:R5C5"
.Action = acOLECreateLink 
.SizeMode = acOLESizeClip 
End With

This will allow you to put a break in the userName = GetUserName line to see if GetUserName is working

David
 

Users who are viewing this thread

Back
Top Bottom