Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Error after importing a macro

  1. #1
    New Member
    Join Date
    Feb 2002
    Location
    Benicia, CA
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have this macro I made that will Format a sheet a certain way. Well I having a hard time explaining to people how to set it up so I made this new sheet that has a box when clicked will take the macro off the desktop and import it into this file I called Personal1.xls and save it in the Windows directory. Then the macro hides the file so it is always in the background and they can run the macro anytime they want. Well I can get it to work fine and all, but when the other lady does it at another site, she gets an error when she goes to exit Excel. The Macro runs fine on the computer and hides it and everything but when she goes to Exit she says she get some Compile Error. I was hoping someone might know what the problem is. Here is the code of how the the Macro Imports the other one:

    Sub Import()
    '
    ' Import Macro
    ' Macro recorded 3/11/2002 by Greg
    '
    '
    ActiveWorkbook.SaveAs FileName:= _
    "C:WindowsPersonal1.xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False
    SendKeys "%{F11}", True
    ActiveWorkbook.VBProject.VBComponents.Import "C:WINDOWSDesktopmodule3.bas"
    SendKeys "%{F4}", True
    SendKeys "%{W}", True
    SendKeys "{H}", True
    End Sub

    Any help would be greatly appreciated. Thank you.

    Greg

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hello,

    It could be the use of Sendkeys (best to avoid it if you can). Does this modified code work?

    Code:
    Sub Import()
    '
    ' Import Macro
    ' Macro recorded 3/11/2002 by Greg
    '
    Dim wb As Workbook
    Set wb = ActiveWorkbook
    
    wb.Windows(1).Visible = False
    wb.VBProject.VBComponents.Import "C:WINDOWSDesktopmodule3.bas"
    wb.SaveAs Filename:= _
    "C:tempPersonal1.xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False
    End Sub
    Hope it helps,
    D

  3. #3
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-21 15:12, dk wrote:
    Hello,

    It could be the use of Sendkeys (best to avoid it if you can). Does this modified code work?

    Code:
    Sub Import()
    '
    ' Import Macro
    ' Macro recorded 3/11/2002 by Greg
    '
    Dim wb As Workbook
    Set wb = ActiveWorkbook
    
    wb.Windows(1).Visible = False
    wb.VBProject.VBComponents.Import "C:WINDOWSDesktopmodule3.bas"
    wb.SaveAs Filename:= _
    "C:tempPersonal1.xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False
    End Sub
    Hope it helps,
    D
    DK is correct...avoid sendkeys if poss...
    plus your need to reference the extensibilty
    in your project file.....


    Ivan

  4. #4
    New Member
    Join Date
    Feb 2002
    Location
    Benicia, CA
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    thanks for the help guys. I figured out which line you use to Hide the sheet but why do you put Windows(1)? What does that mean exactly esp. the 1 in brackets? Also what is meant by the extensibility? thanks again.

    Greg

    [ This Message was edited by: greg0226 on 2002-03-21 22:47 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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