View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown[_6_] Gary Brown[_6_] is offline
external usenet poster
 
Posts: 126
Default Problems executing commands on one file from another

Your syntax is probably off.

Example:

WORKS:
Windows("Test.xls").Activate

DOES NOT WORK
Windows("Test").Activate
Windows("C:\TEMP\Test.xls").Activate

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Eric_G" wrote:

I am executing a macro from one worksheet and wish to perform actions on
another.

With the commands below, I am able to open the existing file called
"destinationfile" which contains a number of worksheets. It's with the 2nd
command line below where I get an error message; for some reason, I am unable
to "ACTIVATE" the file which I just opened (i.e. destinationfile) in order to
select specific worksheets (called "Investment Models E" and "Open Models E")
and save them as a combined PDF document.

NOTE that these commands are being executed from a master excel file (and
not from the destinationfile itself). This is where I am having issues.

Any assistance would be appreciated.

Thanks.


Workbooks.Open Filename:=Destinationfile, UpdateLinks:=3

Windows(destinationfile).Activate

temp_file_name = "File_1.pdf"
Sheets(Array("Investment Models E", "Open Models E")).Select
Sheets("Investment Models E").Activate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
xlfile_drive & temp_file_name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas _
:=False, OpenAfterPublish:=False