Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default workbook_open() sub does not work

Hello,

I have an excel work book with a number of vba macros.
I have placed in "ThisWorkbook" a workbook_open() and workbook_close()
sub procedures. The workbook_close seems to always fire correctly.

The workbook_open() either does not fire , or fires sometimes.

I am trying to change the default directory when the sheet/workbook
opens.

Here is my code for this procedu
I have dimmed the dirPath as Public
Private Sub Workbook_Open()
dirPath = "D:\Excel\SuzanneBrooks"
ChDir dirPath
With ThisWorkbook.Sheets("Risk Control Sheet").lblWorkbook
.ForeColor = &HFF&
.Caption = "Workbook not Loaded"
.Width = 282
.Height = 13
End With
'MsgBox CurDir
End Sub

It seems that the ChDir function does not reliably work?? or I am
missing something in terms of changing directories.

Any tips on this one??

Thanks,

eholz1
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default workbook_open() sub does not work

chdir doesn't change the default drive.

I'd add a line:

chdrive dirpath
chdir dirpath



eholz1 wrote:

Hello,

I have an excel work book with a number of vba macros.
I have placed in "ThisWorkbook" a workbook_open() and workbook_close()
sub procedures. The workbook_close seems to always fire correctly.

The workbook_open() either does not fire , or fires sometimes.

I am trying to change the default directory when the sheet/workbook
opens.

Here is my code for this procedu
I have dimmed the dirPath as Public
Private Sub Workbook_Open()
dirPath = "D:\Excel\SuzanneBrooks"
ChDir dirPath
With ThisWorkbook.Sheets("Risk Control Sheet").lblWorkbook
.ForeColor = &HFF&
.Caption = "Workbook not Loaded"
.Width = 282
.Height = 13
End With
'MsgBox CurDir
End Sub

It seems that the ChDir function does not reliably work?? or I am
missing something in terms of changing directories.

Any tips on this one??

Thanks,

eholz1


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default workbook_open() sub does not work

On Jan 23, 10:54*am, Dave Peterson wrote:
chdir doesn't change the default drive.

I'd add a line:

chdrive dirpath
chdir dirpath



eholz1 wrote:

Hello,


I have an excel work book with a number of vba macros.
I have placed in "ThisWorkbook" a workbook_open() and workbook_close()
sub procedures. *The workbook_close seems to always fire correctly.


The workbook_open() either does not fire , or fires sometimes.


I am trying to change the default directory when the sheet/workbook
opens.


Here is my code for this procedu
I have dimmed the dirPath as Public
Private Sub Workbook_Open()
* * dirPath = "D:\Excel\SuzanneBrooks"
* * ChDir dirPath
* * With ThisWorkbook.Sheets("Risk Control Sheet").lblWorkbook
* * * * .ForeColor = &HFF&
* * * * .Caption = "Workbook not Loaded"
* * * * .Width = 282
* * * * .Height = 13
* * End With
* * 'MsgBox CurDir
End Sub


It seems that the ChDir function does not reliably work?? or I am
missing something in terms of changing directories.


Any tips on this one??


Thanks,


eholz1


--

Dave Peterson


Hello Dave,

Thanks for the tip.. I love this newsgroup!

Eric
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
Workbook_Open does not work Woodsman Excel Programming 1 August 15th 07 07:54 PM
Workbook_Open() does not work Ken Excel Programming 3 July 14th 06 06:51 PM
Can't get Workbook_Open event to work M Smith Excel Programming 1 March 31st 05 06:37 PM
excel vba workbook_open event does not work help please newyuppie[_3_] Excel Programming 2 May 21st 04 09:03 AM


All times are GMT +1. The time now is 01:30 PM.

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

About Us

"It's about Microsoft Excel"