<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Passing Var's from Userform to Module in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507266#M38342</link>
    <description>Thanks for the help again.  Yeah i knew that about my Do while method.  I had fixed that problem earlier so i didn't even think to look for that again.  But thanks for the heads up.  And also thanks for the knowledge and all the kind help.  Much obliged.</description>
    <pubDate>Tue, 27 Dec 2005 20:25:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2005-12-27T20:25:51Z</dc:date>
    <item>
      <title>Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507248#M38324</link>
      <description>How can i pass a variable from my userform to a sub in another module.  &lt;BR /&gt;
I have a userform with a listbox and a command button&lt;BR /&gt;
The user will select an item in the listbox and then click the command button which will call a sub from another module.&lt;BR /&gt;
&lt;BR /&gt;
So in my userform i have this......&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Listbox1_Click&lt;BR /&gt;
Var1 = 10&lt;BR /&gt;
Var2 = 11&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private sub CommandButton1_Click&lt;BR /&gt;
Me.Hide&lt;BR /&gt;
Call DrawItem &lt;BR /&gt;
Me.Show&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Now in Module1 i have the sub DrawItem&lt;BR /&gt;
&lt;BR /&gt;
Public Sub DrawItem ()&lt;BR /&gt;
Var1 = NumbofItems&lt;BR /&gt;
Var2 = NumbofPieces&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
So i need to pass Var1 and Var2 from my userform to the sub in module1. &lt;BR /&gt;
&lt;BR /&gt;
Any Help.  Thanks in advance.</description>
      <pubDate>Sun, 11 Dec 2005 18:18:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507248#M38324</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-11T18:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507249#M38325</link>
      <description>The userform is a class and is accessable from anywhere while it is loaded so userform.listbox1.value is available to any sub (use the userform name ,me is only available in the class module). Sometimes you make a dummy control (set as invisible) to hold the variable temporarily.</description>
      <pubDate>Sun, 11 Dec 2005 19:02:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507249#M38325</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-11T19:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507250#M38326</link>
      <description>Private Sub Listbox1_Click&lt;BR /&gt;
Var1 = 10&lt;BR /&gt;
Var2 = 11&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private sub CommandButton1_Click&lt;BR /&gt;
Me.Hide&lt;BR /&gt;
Call DrawItem (Var1, Var2)&lt;BR /&gt;
Me.Show&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Now in Module1 i have the sub DrawItem&lt;BR /&gt;
&lt;BR /&gt;
Public Sub DrawItem (Var1 as Variant, Var2 as Variant)&lt;BR /&gt;
Var1 = NumbofItems&lt;BR /&gt;
Var2 = NumbofPieces&lt;BR /&gt;
End Sub</description>
      <pubDate>Sun, 11 Dec 2005 22:05:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507250#M38326</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-11T22:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507251#M38327</link>
      <description>Hi Guys, Im still having trouble passing variables between my userform and my module.  I uploaded my program.  Take a look and see where im going wrong.  Its not passing the variables RowNumber and ColNumber to the DrawView Sub in module1.  Many thanks in advance if you figure out what it wrong.</description>
      <pubDate>Sat, 17 Dec 2005 15:16:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507251#M38327</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-17T15:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507252#M38328</link>
      <description>I had a look. It's better if you strip your code down to find the problem (This takes a while)&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
'showopen = Trim(Ofname.lpstrfile)&lt;BR /&gt;
    showopen = Left$(Ofname.lpstrfile, InStr(Ofname.lpstrfile, v&lt;/CODE&gt;bNullChar) - 1)&lt;BR /&gt;
It seems that trim isn't killing the null char.&lt;BR /&gt;
'Fix&lt;BR /&gt;
'.InsertLines .CountOfLines + 1, "Private sub OK_click()"&lt;BR /&gt;
'Set objworkbook = Nothing&lt;BR /&gt;
    'Set WorkSheet = Nothing&lt;BR /&gt;
    'Set Objexcel = Nothing&lt;BR /&gt;
&lt;BR /&gt;
The real problem is that you cant use the term userform1&lt;BR /&gt;
Until it is created. There must be a way to activate it when you have made it but I don't know it.&lt;BR /&gt;
Here's a lame way&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
Dim myForms As VBIDE.VBComponent&lt;BR /&gt;
    Dim YesNo As Boolean&lt;BR /&gt;
    For Each myForms In VBE.ActiveVBProject.VBComponents&lt;BR /&gt;
        If myForms.Type = vbext_ct_MSForm Then&lt;BR /&gt;
            If myForms.Name = "UserForm1" Then&lt;BR /&gt;
                Set U = UserForms.Add("UserForm1")&lt;BR /&gt;
                 'UserForm1.Show&lt;BR /&gt;
                U.Show&lt;BR /&gt;
                YesNo = True&lt;BR /&gt;
                Exit For&lt;BR /&gt;
            End If&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next&lt;BR /&gt;
   &lt;BR /&gt;
    If Not YesNo Then PromptsCollection&lt;BR /&gt;
' and later in Public Sub PromptsCollection&lt;BR /&gt;
ShowForm:&lt;BR /&gt;
'VBA.UserForms.Add(Promptsform.Name).Show&lt;BR /&gt;
Set U = UserForms.Add("UserForm1")&lt;BR /&gt;
U.Show&lt;BR /&gt;
&amp;lt;\code&amp;gt;&lt;/CODE&gt;</description>
      <pubDate>Sat, 17 Dec 2005 21:19:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507252#M38328</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-17T21:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507253#M38329</link>
      <description>Ok so if my problem resides in VBA not activating my userform because it is being created at runtime.  What if i just have the userform already loaded into the DVB and all i add at runtime would be the prompts to the multipage.  Do you think that would work out fine?  &lt;BR /&gt;
I don't want to move all my code around if you think it wouldn't work.</description>
      <pubDate>Mon, 19 Dec 2005 13:20:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507253#M38329</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-19T13:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507254#M38330</link>
      <description>Well what I did, did work and it was late binding. Dim U As Object  This makes sense in your situation.  &lt;BR /&gt;
However I think having the form there in the dvb  will make it easier.</description>
      <pubDate>Mon, 19 Dec 2005 15:38:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507254#M38330</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-19T15:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507255#M38331</link>
      <description>So i created my userform inside my dvb.  But now i am having trouble adding my textboxes etc. &lt;BR /&gt;
I tried this&lt;BR /&gt;
With Mulitpage1.Pages(0).controls.add("forms.textbox.1", "TextHere" , True)&lt;BR /&gt;
&lt;BR /&gt;
Also tried this..&lt;BR /&gt;
&lt;BR /&gt;
Set Mytextbox = Multipage1.add(Promptnamecode, PromptName, 0)&lt;BR /&gt;
Neither will work.  Any Suggestions or i am just gonna go your way.  I just though my code could be cleaner if i just created the userform and added the elements.</description>
      <pubDate>Wed, 21 Dec 2005 03:51:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507255#M38331</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-21T03:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507256#M38332</link>
      <description>macleodjb &lt;BR /&gt;
 &lt;BR /&gt;
Sub RunTimeButton()&lt;BR /&gt;
'   Adds a button at runtime&lt;BR /&gt;
&lt;BR /&gt;
'   Make sure access to the VBProject is allowed&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Set x = ActiveWorkbook.VBProject&lt;BR /&gt;
    If Err &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
        MsgBox "Your security settings do not allow this macro to run.", vbCritical&lt;BR /&gt;
        On Error GoTo 0&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
    Dim Butn As CommandButton&lt;BR /&gt;
    Set Butn = UserForm1.Controls.Add("Forms.CommandButton.1")&lt;BR /&gt;
    With Butn&lt;BR /&gt;
        .Caption = "Added at runtime"&lt;BR /&gt;
        .Width = 100&lt;BR /&gt;
        .Top = 10&lt;BR /&gt;
    End With&lt;BR /&gt;
    UserForm1.Show&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sub DesignTimeButton()&lt;BR /&gt;
'   Adds a button at design-time&lt;BR /&gt;
&lt;BR /&gt;
'   Make sure access to the VBProject is allowed&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Set x = ActiveWorkbook.VBProject&lt;BR /&gt;
    If Err &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
        MsgBox "Your security settings do not allow this macro to run.", vbCritical&lt;BR /&gt;
        On Error GoTo 0&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
    Dim Butn As CommandButton&lt;BR /&gt;
    Set Butn = ThisWorkbook.VBProject.VBComponents("UserForm1") _&lt;BR /&gt;
      .Designer.Controls.Add("Forms.CommandButton.1")&lt;BR /&gt;
    With Butn&lt;BR /&gt;
        .Caption = "Added at design-time"&lt;BR /&gt;
        .Width = 120&lt;BR /&gt;
        .Top = 40&lt;BR /&gt;
    End With&lt;BR /&gt;
    VBA.UserForms.Add("UserForm1").Show&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Fred C.</description>
      <pubDate>Wed, 21 Dec 2005 13:46:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507256#M38332</guid>
      <dc:creator>fxcastil</dc:creator>
      <dc:date>2005-12-21T13:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507257#M38333</link>
      <description>Bear with me but im a little confused.  I haven't used the activeworkbook method.  I have to add controls at runtime to a multipage on a userform i have already created at design time. So how can i manipulate the syntax you just gave me to fit what i need?</description>
      <pubDate>Wed, 21 Dec 2005 15:25:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507257#M38333</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-21T15:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507258#M38334</link>
      <description>These are Excel samples&lt;BR /&gt;
&lt;BR /&gt;
Try these in Excel to see how to add forms at design time or run time . Run time forms are never visible in the IDE development environment and design time forms are added to your project and are therfore visible in the  IDE development environment. To run these in Excel set the macro/trusted source setting to allow acess to VBE project see *.jpg file&lt;BR /&gt;
&lt;BR /&gt;
I bet this method of adding forms is not nedded in 99.99% of the time. A reason to add controls at design time and not run time. Might be if you had a userform with 100 buttons and 100 labels and 100 frames and you did not to create all these by hand. Or if you had many similar projects which use the identical form except for qty of controls and you want to have a configurable userform &lt;BR /&gt;
&lt;BR /&gt;
Fred Castillo</description>
      <pubDate>Wed, 21 Dec 2005 17:50:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507258#M38334</guid>
      <dc:creator>fxcastil</dc:creator>
      <dc:date>2005-12-21T17:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507259#M38335</link>
      <description>Thanks for the samples.  But what i need is to add controls at runtime inside the IDE in autocad.  I am only using excel to get variables from.  And the reason the controls need to be added at runtime is that the source file in excel will have different prompts for each file called.  So they will be constantly changing.  The only things that will remain constant will be the listbox and the OK and Cancel buttons. I just need to know why my code wasn't adding the controls to my existing multipage.  See above.</description>
      <pubDate>Wed, 21 Dec 2005 18:48:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507259#M38335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-21T18:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507260#M38336</link>
      <description>The samples I gave are to give you a tutorial on using the &lt;BR /&gt;
VBA extensibility library which is what you are using to add controls at runtime . The samples are VBA dependent and also work the same in any VBA host such as Autocad.&lt;BR /&gt;
&lt;BR /&gt;
As far your example you are trying to add the control to a multipage . The userform is the container for the controls not the multi-page . The multipage is another control which also resides on the userform.&lt;BR /&gt;
&lt;BR /&gt;
Run the examples I gave you they are a good tutor for using the VBA extensibility library&lt;BR /&gt;
&lt;BR /&gt;
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3BQ204330&lt;BR /&gt;
&lt;BR /&gt;
http://support.microsoft.com/default.aspx?scid=kb;en-us;185774&lt;BR /&gt;
&lt;BR /&gt;
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=432&lt;BR /&gt;
&lt;BR /&gt;
Fred Castillo</description>
      <pubDate>Thu, 22 Dec 2005 02:45:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507260#M38336</guid>
      <dc:creator>fxcastil</dc:creator>
      <dc:date>2005-12-22T02:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507261#M38337</link>
      <description>thanks fred.  I think i got it now.  Appreciate it.</description>
      <pubDate>Thu, 22 Dec 2005 03:01:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507261#M38337</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-22T03:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507262#M38338</link>
      <description>I tried to make it work the other way but had no luck.  Byco I tried to do it your way but i think im placing your code into the module incorrectly.  Can you update my code and repost it the way you got it to function properly.  I'd appreciate it greatly.  Thanks alot.</description>
      <pubDate>Sat, 24 Dec 2005 17:14:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507262#M38338</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-24T17:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507263#M38339</link>
      <description>Merry Christmas</description>
      <pubDate>Sun, 25 Dec 2005 16:29:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507263#M38339</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-25T16:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507264#M38340</link>
      <description>Thanks alot.  You are definetly a much better programmer than i am.  Although im still learning.  There is one issue that still remains though.  When you hit the draw view button after you have already clicked it once it doesn't draw.  So i can go through and select plan view and select the point on the screen and it draws the view fine, if i want to draw the plan view again without ending the process it will allow me to select the point again but will not draw the geometry over again.  I haven't been able to dig through what you did yet from the holidays but i'm gonna atleast try.  If you feel like checking into why please do otherwise i'm good with just getting this far.  Greatly appreciate what you've done for me this far.</description>
      <pubDate>Tue, 27 Dec 2005 14:42:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507264#M38340</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-27T14:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507265#M38341</link>
      <description>Mac you dont want to declare things at the module level if you dont need to for example  Do Until Name = "[End]", when Name is declared at the modular level after the first pass its value is End so you cant continue whereas dimming it in the sub its value is reset to "".&lt;BR /&gt;
&lt;BR /&gt;
Also found that once you set an object =userform1 its best to take all references to userform1 away as they start the Userform_initialize sub.</description>
      <pubDate>Tue, 27 Dec 2005 17:09:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507265#M38341</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-27T17:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Var's from Userform to Module</title>
      <link>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507266#M38342</link>
      <description>Thanks for the help again.  Yeah i knew that about my Do while method.  I had fixed that problem earlier so i didn't even think to look for that again.  But thanks for the heads up.  And also thanks for the knowledge and all the kind help.  Much obliged.</description>
      <pubDate>Tue, 27 Dec 2005 20:25:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/passing-var-s-from-userform-to-module/m-p/1507266#M38342</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-12-27T20:25:51Z</dc:date>
    </item>
  </channel>
</rss>

