Consulting

Results 1 to 7 of 7

Thread: How to Declare Object Variable with Direct Memory Access?

  1. #1

    How to Declare Object Variable with Direct Memory Access?

    I want to declare a variable by directly writing the declaration directly to memory. i assume we need to create in memory:

    • Variable name and type info. Eg, "MyWorkbook"

    I assume the variable can be created using commonly available methods such as StrPtr, VarPtr, ObjPtr, CopyMemory, etc.

    Once created, then the variable could be instantiated with normal VBA (not direct memory access), using the variable-name as normal. Eg:
    Set MyWorkbook = Workbooks(2)

    Assume 64-bit (PtrSafe declarations etc)
    Office 2016
    Last edited by johnywhy; 07-22-2021 at 03:58 PM.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Might be impossible, but Why?
    Last edited by Paul_Hossler; 07-22-2021 at 10:22 PM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Quote Originally Posted by Paul_Hossler View Post
    Might be impossible, but Why?
    Power, speed, flexibility, ability to declare variables with strings, ability to declare variables in immediate pane, unknown future applications. To expand my skillset.

    Also asked at
    https://stackoverflow.com/questions/...-memory-access

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,635
    Use With ... End With instead of Set.

  5. #5
    Quote Originally Posted by snb View Post
    Use With ... End With instead of Set.
    wrong thread?

  6. #6
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,635
    Please read again and try to understand.

  7. #7
    Quote Originally Posted by snb View Post
    Please read again and try to understand.
    no idea

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
  •