![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Location: Benicia, CA
Posts: 31
|
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 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
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 D |
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
plus your need to reference the extensibilty in your project file..... Ivan |
|
|
|
|
|
|
#4 |
|
New Member
Join Date: Feb 2002
Location: Benicia, CA
Posts: 31
|
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 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|