ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   concatenation question (https://www.excelbanter.com/excel-discussion-misc-queries/208702-concatenation-question.html)

teepee[_3_]

concatenation question
 
Hello

I'm guessing this isn't allowed but I'd welcome confirmation

Can one concatenate a variable into a VBA command

So for example

instead of userform1. windowsmediaplayer1.controls.currentposition

could you have

userform1. windowsmediaplayer & ("range a1") & .controls.currentposition

If so what would the correct syntax be?

Many thanks






Don Guillett

concatenation question
 
In WHICH group do you want an answer?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teepee" wrote in message
...
Hello

I'm guessing this isn't allowed but I'd welcome confirmation

Can one concatenate a variable into a VBA command

So for example

instead of userform1. windowsmediaplayer1.controls.currentposition

could you have

userform1. windowsmediaplayer & ("range a1") & .controls.currentposition

If so what would the correct syntax be?

Many thanks







teepee[_3_]

concatenation question
 

"Don Guillett" wrote in message
...
In WHICH group do you want an answer?


err this one?



Don Guillett

concatenation question
 

Then try your solution and post back
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teepee" wrote in message
...

"Don Guillett" wrote in message
...
In WHICH group do you want an answer?


err this one?




teepee[_3_]

concatenation question
 

"Don Guillett" wrote in message
...

Then try your solution and post back


compile error: method or data member not found
and it highlights the words ".windowsmediaplayer"



teepee[_3_]

concatenation question
 
To test I have the following macro, where cell a1 contains the value 1

Sub test ()
dim value as long
value = userform1.windowsmediaplayer & range ("a1") &
..controls.currentposition
'value = userform1.windowsmediaplayer1controls.currentposit ion
msgbox value
end sub

when I hash out the third line and unhash the fourth it successfully return
the messagebox value zero.

Most grateful if anyone can tell me if (a) I'm wasting my time with this
approach or (b) the correct syntax




Don Guillett

concatenation question
 
Try it this way

Sub test ()
dim value as long
value = userform1.windowsmediaplayer" & range ("a1") &
".controls.currentposition
'value = userform1.windowsmediaplayer1controls.currentposit ion
msgbox value
end sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teepee" wrote in message
...
To test I have the following macro, where cell a1 contains the value 1

Sub test ()
dim value as long
value = userform1.windowsmediaplayer & range ("a1") &
.controls.currentposition
'value = userform1.windowsmediaplayer1controls.currentposit ion
msgbox value
end sub

when I hash out the third line and unhash the fourth it successfully
return the messagebox value zero.

Most grateful if anyone can tell me if (a) I'm wasting my time with this
approach or (b) the correct syntax





teepee[_3_]

concatenation question
 
Thanks Don

It reports a syntax error however



"Don Guillett" wrote in message
...
Try it this way

Sub test ()
dim value as long
value = userform1.windowsmediaplayer" & range ("a1") &
".controls.currentposition
'value = userform1.windowsmediaplayer1controls.currentposit ion
msgbox value
end sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teepee" wrote in message
...
To test I have the following macro, where cell a1 contains the value 1

Sub test ()
dim value as long
value = userform1.windowsmediaplayer & range ("a1") &
.controls.currentposition
'value = userform1.windowsmediaplayer1controls.currentposit ion
msgbox value
end sub

when I hash out the third line and unhash the fourth it successfully
return the messagebox value zero.

Most grateful if anyone can tell me if (a) I'm wasting my time with this
approach or (b) the correct syntax







Don Guillett

concatenation question
 
I don't use many userforms but try this

Sub stringit()
'ms = "userform1. windowsmediaplayer1.controls.currentposition"
ms = "userform1. windowsmediaplayer" & Range("a1") &
".controls.currentposition"
MsgBox ms
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teepee" wrote in message
...
Thanks Don

It reports a syntax error however



"Don Guillett" wrote in message
...
Try it this way

Sub test ()
dim value as long
value = userform1.windowsmediaplayer" & range ("a1") &
".controls.currentposition
'value = userform1.windowsmediaplayer1controls.currentposit ion
msgbox value
end sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teepee" wrote in message
...
To test I have the following macro, where cell a1 contains the value 1

Sub test ()
dim value as long
value = userform1.windowsmediaplayer & range ("a1") &
.controls.currentposition
'value = userform1.windowsmediaplayer1controls.currentposit ion
msgbox value
end sub

when I hash out the third line and unhash the fourth it successfully
return the messagebox value zero.

Most grateful if anyone can tell me if (a) I'm wasting my time with this
approach or (b) the correct syntax








Pecoflyer[_9_]

concatenation question
 

Use code tags around code. Posting code without them makes your code
hard to read and difficult to be copied for testing. Highlight your code
and click the # at the top of your post window.


--
Pecoflyer
------------------------------------------------------------------------
Pecoflyer's Profile: http://www.thecodecage.com/forumz/member.php?userid=14
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=24214


teepee[_3_]

concatenation question
 

"Don Guillett" wrote in message
...
I don't use many userforms but try this


sadly that returns the information as a text string "userform1.
windowsmediaplayer1.controls.currentposition" rather than as a value.




teepee[_3_]

concatenation question
 

"Pecoflyer" wrote in message
...

Use code tags around code. Posting code without them makes your code
hard to read and difficult to be copied for testing. Highlight your code
and click the # at the top of your post window.


Apologies I'm using outlook express today which doesn't seem to do such
things




All times are GMT +1. The time now is 04:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com