p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

vba_excel thread: Problem opening file within procedure

Message #1 by "Paul Hickman" <paul.hickman@l...> on Thu, 24 Jan 2002 11:24:09 -0000
Dear all,

My problem is this:
I have a button called PRINT/SAVE  which I use to print and save the doc. I
also have a log file which I need to open to write to before saving.
When I use the button, the file does not open, however, if I just use the
standard PRINT or SAVE button the code runs OK and the file opens.

This is the routine where the button code resides:

    Sub PrintAndSaveButton_Click()

I then jump in and out if the following:
    Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As Boolean)

    Sub ActivateWorkbook2()

    Sub CheckQuoteLogOpen()

    Function IsWorkbookOpen(WorkbookName As String) As Boolean

The line that is the problem is within: Sub ActivateWorkbook2()
and is:   Set Wkb = Workbooks.Open(filename:=stFullName), it seems to be
ignored and the consequence is apparant later in Sub ActivateWorkbook2()
because I am trying to write to the 'Still Closed' file. - SUBSCRIPT OUT OF
RANGE is the error message.

If I save the file using the save button I dont get a problem opening the
other file and the only difference in the procedure is that I dont enter the
"Sub PrintAndSaveButton_Click()" procedure.

Any ideas of the problem would really be appreciated, I am at the moment

Thanks in advance


  Return to Index