My Workbook is always hidden when I open it?
Try removing the "on error resume next" statement.
If something goes wrong, that line will hide the error.
And the activewindow may not be what you think it is.
DDawson wrote:
I don't know what I've done to it. I have on open and before save events, but
I can't see the problem. I want the document to open visible.
Can you have a look and tell me if there's something I'm missing?
Private Sub Workbook_Open()
Dim wbk1 As Workbook
Dim wbk2 As Workbook
On Error Resume Next
Set wbk1 = Workbooks("Export_Requests.csv")
Set wbk2 = Workbooks("Project Summary.xls")
If wbk1 Is Nothing Then
ChDir "I:\A&T Contracts\000 Utilities\"
Set wbk1 = Workbooks.Open("I:\A&T Contracts\000 Utilities\Project
Specific\Contract Docs\Integrated Utility Services\Export_Requests.csv")
ActiveWindow.Visible = False
End If
If wbk2 Is Nothing Then
ChDir "I:\A&T Contracts\000 Utilities\Project Specific\Contract
Docs\Integrated Utility Services\Option E\Payment\"
Set wbk4 = Workbooks.Open("I:\A&T Contracts\000 Utilities\Project
Specific\Contract Docs\Integrated Utility Services\Option E\Payment\Project
Summary.xls")
ActiveWindow.Visible = False
End If
End Sub
'*******
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim i As Integer
Dim sPath As String
Dim sFilename As String
Application.ScreenUpdating = False
Range("A1").Select
'Backup to Flashdrive
msg = "Do you want to save a Backup to your Flashdrive?"
Style = vbYesNo + vbInformation + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
For i = 67 To 90
Set drspec = fs.GetDrive(Chr(i))
If drspec.drivetype = 1 Then
'MsgBox "Drive " & Chr(i) & " is the removable drive"
sPath = Chr(i) & ":\Work\Solutions Folder\IUS MONITOR\"
sFilename = "IUS Monitor " & _
Format(DateSerial(Year(Date), Month(Date), _
Day(Date)), "dd MM yy") & ".xls"
ans = MsgBox("Save File as " & sFilename & "?")
If ans = vbOK Then
'Check Path exists
If CreateObject("Scripting.FileSystemobject") _
.folderexists(sPath) = False Then
MkDir sPath
End If
ActiveWorkbook.SaveCopyAs sPath & sFilename
End If
i = 90
End If
Next i
Else
ActiveWorkbook.Activate
End If
Application.ScreenUpdating = True
End Sub
'Thanks
'Dylan
--
Dave Peterson
|