Performing code without opening the Workbook

M

Marishah Warren

The below working code opens the workbook and pastes cells as links from
another workbook. How can I make the below operation work without having to
actually open the workbook located in '"Workbooks.Open
Worksheets(4).Range("A6").Value"?

Workbooks.Open Worksheets(4).Range("A6").Value
Range("A1").Select
ActiveSheet.Paste Link:=True


Thank you

Todd Huttenstine
 
C

Colo

Hi Todd, :)
You can use Application.ExecuteExcel4Macro, something like..


Code:
--------------------

Sub Test1()
Dim strTarget As String
strTarget = "'" & "CHANGE HERE TO FULL PATH to Book2.xls" & "\[Book2.xls]Sheet4'!R6C1"
Selection.Value = Application.ExecuteExcel4Macro(strTarget)
End Sub
 
S

Shailesh Shah

Hi Todd,

If you want a value from closed workbook then try this,

Sub Test()
ActiveCell.Formula = "='c:\mypath\[mywbname.xls]mysheetname'!a1"

'to remove link convert it to value
ActiveCell.Value = ActiveCell.Value

End Sub


Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Top