Error after importing a macro

greg0226

New Member
Joined
Feb 24, 2002
Messages
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
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,017
Members
448,937
Latest member
BeerMan23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top