#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Close file

using code I am a opening a worksheet (source), copying data & pasting in
worksheet (target). Target file contains code as well.

My requiredment is after copy/pasting, the source file automatically close,
keep in mind source filename keeps changing.

folloiwng code opens file
ChDir _
"\\ccgrp2.office.adroot.gc.net\OCt\Desktop Deployment\Backlog FY09
Project\Received Inventory Files\"
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls")

Regards
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Close file

Try the below

Dim wb as Workbook

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
Set wb = Workbooks.Open (FName)
'copy paste code here
wb.Close False


If this post helps click Yes
---------------
Jacob Skaria


"Atif" wrote:

using code I am a opening a worksheet (source), copying data & pasting in
worksheet (target). Target file contains code as well.

My requiredment is after copy/pasting, the source file automatically close,
keep in mind source filename keeps changing.

folloiwng code opens file
ChDir _
"\\ccgrp2.office.adroot.gc.net\OCt\Desktop Deployment\Backlog FY09
Project\Received Inventory Files\"
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls")

Regards

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Close file

Sub CopyPastInMasterTrackingWB()
Dim FName As Variant

ChDir _

"\\officeSCCHOME1.office.adroot.bmogc.net\UserData $\atanvee\home\Development\"
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls")
Set wb = Workbooks.Open(FName)

If FName < False Then
Workbooks.Open (FName)
Range("A2:AM999").Select
Selection.Copy

Windows("temp OTHR Backlog Reduction - MASTER TRACKING
WORKBOOK.xls").Activate
Range("A1").Select
Selection.End(xlDown).Offset(1, 0).Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If

wb.Close False (error 424 - object required)

its giveing error at wb.close

any how following code worked for me:
Application.DisplayAlerts = False
Windows(2).Activate
ActiveWindow.Close

Thank you! I will like to know whats worng in wb.close


"Jacob Skaria" wrote:

Try the below

Dim wb as Workbook

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
Set wb = Workbooks.Open (FName)
'copy paste code here
wb.Close False


If this post helps click Yes
---------------
Jacob Skaria


"Atif" wrote:

using code I am a opening a worksheet (source), copying data & pasting in
worksheet (target). Target file contains code as well.

My requiredment is after copy/pasting, the source file automatically close,
keep in mind source filename keeps changing.

folloiwng code opens file
ChDir _
"\\ccgrp2.office.adroot.gc.net\OCt\Desktop Deployment\Backlog FY09
Project\Received Inventory Files\"
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls")

Regards

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Everytime i close an excel file, it creates a new backup file p Excel Discussion (Misc queries) 3 November 22nd 07 08:13 AM
Close & save a file at set time only IF the file is open Clivey_UK[_5_] Excel Programming 2 May 1st 06 06:19 PM
Close file and run macro from newly opened file Pradip Jain Excel Programming 1 April 23rd 05 11:39 PM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"