+ Reply to Thread
Results 1 to 19 of 19

URGENT - have code that only works for 32 bit-need 64 too!

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    URGENT - have code that only works for 32 bit-need 64 too!

    is it just as simple as changing it to 64? in the code... it cant be im assuming .

    this is the part of the code which states 32 bit


    'Code to open ANY files double clicking on cell or range of cells
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                                          (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
                                           ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Const SW_SHOW            As Long = 5&

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    If it will only be run on 2010 or later, you can just use:

    Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
    If your code stores the return value in a variable, make sure to declare that variable as LongPtr not Long.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    I really am lost with this code... to be blunt. is that ALL I have to change in that code to allow a person using 64 bit to use the spreadsheet>>

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    Yes, it is.

  5. #5
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    if you can sort this, I would APPRECIATE it a lot

  6. #6
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    I tried but when I open it on 64 bit it still comes up with errors. and says something like "I need to add a ptrsafe attribute

    this is full code..

    'Code to open ANY files double clicking on cell or range of cells
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                                          (ByVal hWnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
                                           ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Const SW_SHOW            As Long = 5&
    'change path as required.
    Sub OpenFile(strFilePath As String)
       ShellExecute Application.hWnd, "Open", strFilePath, 0&, 0&, SW_SHOW
    End Sub
    
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, cancel As Boolean)
        
        If Not Intersect(Target, Range("BJ6")) Is Nothing Then
            cancel = True
            Sheets("Drawings").Select
        ElseIf Not Intersect(Target, Range("AF6")) Is Nothing Then
            cancel = True
            Sheets("Finance").Select
        ElseIf Not Intersect(Target, Range("AP6")) Is Nothing Then
            cancel = True
            Sheets("Design").Select
        ElseIf Not Intersect(Target, Range("AZ6")) Is Nothing Then
            cancel = True
            Sheets("Materials").Select
        ElseIf Not Intersect(Target, Range("BT6")) Is Nothing Then
            cancel = True
            Sheets("DFP").Select
        ElseIf Not Intersect(Target, Range("CD6")) Is Nothing Then
            cancel = True
            Sheets("Delivery & Docs").Select
    
        End If
    
    End Sub

  7. #7
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    sorry didn edit code the way you told me.. hang on

  8. #8
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    any ideas?????

  9. #9
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    receiving errors about the rest of the code now - e.g the string parameters etc..

    this is full code after edit...

    I can now open spreadsheet but the links to files don't work

    'Code to open ANY files double clicking on cell or range of cells
    
    Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                                          (ByVal hWnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
                                           ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
    Const SW_SHOW            As Long = 5&
    'change path as required.
    Sub OpenFile(strFilePath As String)
       ShellExecute Application.hWnd, "Open", strFilePath, 0&, 0&, SW_SHOW
    End Sub
    
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, cancel As Boolean)
        
        If Not Intersect(Target, Range("BJ6")) Is Nothing Then
            cancel = True
            Sheets("Drawings").Select
        ElseIf Not Intersect(Target, Range("AF6")) Is Nothing Then
            cancel = True
            Sheets("Finance").Select
        ElseIf Not Intersect(Target, Range("AP6")) Is Nothing Then
            cancel = True
            Sheets("Design").Select
        ElseIf Not Intersect(Target, Range("AZ6")) Is Nothing Then
            cancel = True
            Sheets("Materials").Select
        ElseIf Not Intersect(Target, Range("BT6")) Is Nothing Then
            cancel = True
            Sheets("DFP").Select
        ElseIf Not Intersect(Target, Range("CD6")) Is Nothing Then
            cancel = True
            Sheets("Delivery & Docs").Select
    
        End If
    
    End Sub

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    What errors?

  11. #11
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    just saying there are problems with strings etc cant be single or something

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    What is the actual error message?

  13. #13
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    bear with me.

  14. #14
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    this is the error now?
    Attached Images Attached Images

  15. #15
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: URGENT - have code that only works for 32 bit-need 64 too!


    When transposing, why cut some instruction from original working 32 bits version ?‼

    Just read your original post and see what is lacking …

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    OK - you need to add the word 'Private' at the start of the 'Declare Function ...' line:
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                                          (ByVal hWnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
                                           ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
    because it's in a worksheet code module.

  17. #17
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: URGENT - have code that only works for 32 bit-need 64 too!


    Yes, the answer is in the error message …

  18. #18
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    I haven't cut any code. I know it looks that way from pic.. but I haven't. its all there. until I try to use a link and then that pops up and looks like a big chunk of the code is gone but it hasnt

  19. #19
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: URGENT - have code that only works for 32 bit-need 64 too!

    did I say you guys were legends? if not I am now. thanks it works now! finally!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA code upgradation. . . .very urgent
    By jhau1234 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 06-03-2013, 10:49 AM
  2. VBA code to show user performance in a program
    By KH123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2012, 06:08 PM
  3. URGENT VBA Code Required
    By tf91 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-02-2012, 09:41 AM
  4. Code works only once
    By Hein in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-13-2009, 07:27 AM
  5. Code works for any WBK except the PMW
    By Mark Tangard in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2005, 07:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1