Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default parameter to open file name in macro

I am trying to write a macro to print many worksheets from many workbook.
However, each month some of the worksheet have different naming based on the
month. For example: "NOV_PJ" and the next month "DEC_PJ". is there a way to
have a parameter in the macro to ask for the file name before having the
macro print out the worksheet?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default parameter to open file name in macro

Assuming you had your loop set up as:

For Each Wb In myFolder
For Each Ws In Wb
If Not Ws Is Nothing Then
shName = Ws.Name
MsgBox shName
Ws PrintOut
End If
Next
Next

Where the message box is inserted above you could use a
Yes/No criteria to determine if you want to print the
particular sheet and insert code that would skip to the next
sheet if print is not required.

Without seeing your actural code, I don't know if this is what
you were looking for, but it should give you an idea of how to
handle it.

"KrisN" wrote:

I am trying to write a macro to print many worksheets from many workbook.
However, each month some of the worksheet have different naming based on the
month. For example: "NOV_PJ" and the next month "DEC_PJ". is there a way to
have a parameter in the macro to ask for the file name before having the
macro print out the worksheet?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default parameter to open file name in macro

I am still a little lost. I am new to macro in excel and I used the record
macro to create this the following code:

Sub Sales_Strategy_FX()

Workbooks.Open Filename:="G:\MARKET\PSI\COPIER\2007B PSI\Jan 07B FX.xlsx", _
UpdateLinks:=0
Sheets("Sales Flash").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("Half to Date").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1

End Sub

The path that list the file name Jan 07B FX.xlsx is the file that would
change each month...ergo next month the file name would be Feb 07B FX. This
is were I need the parameter or msgbox to ask for the file I want to print.
The yes/no message box to print and or skip to next sheet would also be a
plus and is beyond my knowledge. If you could help me with this code as well
I would greatly appreciate it.

"JLGWhiz" wrote:

Assuming you had your loop set up as:

For Each Wb In myFolder
For Each Ws In Wb
If Not Ws Is Nothing Then
shName = Ws.Name
MsgBox shName
Ws PrintOut
End If
Next
Next

Where the message box is inserted above you could use a
Yes/No criteria to determine if you want to print the
particular sheet and insert code that would skip to the next
sheet if print is not required.

Without seeing your actural code, I don't know if this is what
you were looking for, but it should give you an idea of how to
handle it.

"KrisN" wrote:

I am trying to write a macro to print many worksheets from many workbook.
However, each month some of the worksheet have different naming based on the
month. For example: "NOV_PJ" and the next month "DEC_PJ". is there a way to
have a parameter in the macro to ask for the file name before having the
macro print out the worksheet?

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
Open Excel file from VB and open MACRO no1jimmyman Excel Discussion (Misc queries) 0 February 14th 11 10:10 PM
Open Access Macro, then put a value into a parameter field BigPig Excel Programming 1 June 27th 07 05:49 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Macro to call a file that has a auto open macro in the file itself [email protected] Excel Programming 1 August 5th 05 06:39 AM
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 06:44 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"