Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Beyond AUTO_OPEN
My question regarding code below is that I'm not sure how/where to place the code. At this point, the extent of my VBA experience is AUTO_OPEN and AUTO_CLOSE. I would like to call his code as the workbook is opening
How do I place the code? ...within AUTO_OPEN? ...called from AUTO_OPEN? ...do I create a standard module or class module or function and place the code there??? Appreciate any suggestions out there Thanks, Warren R -------------------------------------------------------- Here is the code to pull C: Volume Serial Number given to me from Rob van Gelder.. Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Lon Sub test( Const cMaxPath = 256, cDrive = "C:\ Dim strTemp As String, lngRet As Lon Dim lngVolSerial As Long, strVolName As String * cMaxPat Dim lngMaxCompLen As Long, lngFileSysFlags As Lon Dim strFileSysName As String * cMaxPat lngRet = GetVolumeInformation(cDrive, strVolName, cMaxPath, lngTemp, lngMaxCompLen, lngFileSysFlags, strFileSysName, cMaxPath strTemp = Format(Hex(lngTemp), "00000000" strTemp = Left(strTemp, 4) & "-" & Right(strTemp, 4 MsgBox strTem End Su |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Beyond AUTO_OPEN
Depend upon how you want it to run. If you want it to run when the workbook
opens, rename the sub Test to Auto_Open. If you want it to be activated by a button, just assign Test to it. Put the code in a standard code module. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "WarrenR" wrote in message ... My question regarding code below is that I'm not sure how/where to place the code. At this point, the extent of my VBA experience is AUTO_OPEN and AUTO_CLOSE. I would like to call his code as the workbook is opening. How do I place the code? ...within AUTO_OPEN? ...called from AUTO_OPEN? ....do I create a standard module or class module or function and place the code there??? Appreciate any suggestions out there? Thanks, Warren R. --------------------------------------------------------- Here is the code to pull C: Volume Serial Number given to me from Rob van Gelder... Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long Sub test() Const cMaxPath = 256, cDrive = "C:\" Dim strTemp As String, lngRet As Long Dim lngVolSerial As Long, strVolName As String * cMaxPath Dim lngMaxCompLen As Long, lngFileSysFlags As Long Dim strFileSysName As String * cMaxPath lngRet = GetVolumeInformation(cDrive, strVolName, cMaxPath, lngTemp, _ lngMaxCompLen, lngFileSysFlags, strFileSysName, cMaxPath) strTemp = Format(Hex(lngTemp), "00000000") strTemp = Left(strTemp, 4) & "-" & Right(strTemp, 4) MsgBox strTemp End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
AUTO_OPEN | Excel Discussion (Misc queries) | |||
Auto_open and more.... | New Users to Excel | |||
Auto_open and more.... | New Users to Excel | |||
Auto_open | Excel Discussion (Misc queries) | |||
auto_open? | Excel Discussion (Misc queries) |