Consulting

Results 1 to 6 of 6

Thread: Import data from Userform to Module in powerpoint vba

  1. #1

    Import data from Userform to Module in powerpoint vba

    It may be a simple but I can not configure it out.


    1. I have userform1 & where I store height & width value of my rectangle shape in form of array.
    2. Now I require that value(array) in my module2.


    How to import that array in module2.


    Any solution will be highly appreciated.


    In the Userform1
    Private Sub CommandButton1_Click()
    Dim h As Double
    Dim w As Double
    Dim port_array() As Variant
    ReDim port_array(0 To 1)
    h = Me.TextBoxHeight.Value
    w = Me.TextBoxWidth.Value
    End Sub

    In the module2
    Sub import_array()
    Dim bshp as shape
    Dim h As Double
    Dim w As Double
    Dim port_array() As Variant
    w = port_array(0)
    h = port_array(1)
    Set bshp = ActivePresentation.Slides(1).Shapes("rectangle1")
    With bshp
        .Width = w
        .Height = h
    End With
    End Sub

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    335
    Location
    Why an array and not simply two variables? Why use ReDim instead of defining the array bounds when it is declared?

    Your button code is not even populating array.

    Possibly declare array or number variables as global?

    Where do you call import_array() procedure?
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    You are right sir, simply two variables is much easy. but how to declare variables as global in userform1.

  4. #4
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    335
    Location
    You declare the variables in general module header then they can be referred to by any procedure.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    so, declare variable x in module2 above header. in userform1 store value in x i.e x=5. now how to get value of x in module2. I need to call
    show.userform1 in module2

  6. #6
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    335
    Location
    I've never used forms in PowerPoint.

    Somehow a procedure opens form, user input on form sets variables, another procedure uses variables.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •