automate windows prompt responses

dmurphy1991

New Member
Joined
Jan 10, 2014
Messages
22
Ok so my below code basically opens another macro enabled workbook takes out a sheet (with a specific name) and pastes it into my active worksheet, Unfortunately when opening the file (to be copied from) i have to respond whether to enable macros or not. As this is within my code by opening another sheet i wasn't sure if there was a way to auto select 'enable'.

Alternatively is there a way to adjust y code so the file never has to be physically opened? by the user still specifies the file to be used?

Any help is really appreciated thanks!

Option Explicit
Sub Sample()
Dim wb1 As Workbook, wb2 As Workbook
Dim Ret1
Set wb1 = ActiveWorkbook
'~~> Get the first File
Ret1 = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _
, "Please select the setup automator file")
If Ret1 = False Then Exit Sub
Set wb2 = Workbooks.Open(Ret1)
Application.DisplayAlerts = False
wb1.Sheets.Add.Name = "Setup Data Export"
wb2.Activate
Sheets("Setup Data").Select
Range("A14").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A14:CP14").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWindow.SmallScroll Down:=9
Selection.Copy
wb1.Sheets("Setup Data Export").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
wb2.Close SaveChanges:=False
Columns("A:A").Select
Range(Selection, Selection.End(xlToRight)).Select
Columns("A:CP").EntireColumn.AutoFit
ActiveWindow.ScrollColumn = 73
ActiveWindow.ScrollColumn = 71
ActiveWindow.ScrollColumn = 68
ActiveWindow.ScrollColumn = 64
ActiveWindow.ScrollColumn = 62
ActiveWindow.ScrollColumn = 56
ActiveWindow.ScrollColumn = 44
ActiveWindow.ScrollColumn = 29
ActiveWindow.ScrollColumn = 1
Range("A2").Select



End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
You can't automatically enable macros in VBA. If you could macro security would hardly be secure. What macros are in the workbook that is being opened?
 
Upvote 0
it's a very large file with multiple macros in it. but im just trying to extract the finished/ final data from a specific sheet. technically the file im extracting from is 'finished' so wont need macros enabled as i wont be using any of them. i couldn't get a method of extrating the data without opening the file to open to work though.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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