Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Beyond AUTO_OPEN

Also see the response(s) in the original discussion.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
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
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
AUTO_OPEN Bob Barnes Excel Discussion (Misc queries) 2 February 6th 08 03:03 AM
Auto_open and more.... pcor New Users to Excel 2 December 1st 06 02:07 AM
Auto_open and more.... Mike New Users to Excel 0 November 30th 06 07:13 PM
Auto_open dan Excel Discussion (Misc queries) 7 May 21st 06 10:41 AM
auto_open? Jack Sons Excel Discussion (Misc queries) 0 February 22nd 05 09:16 PM


All times are GMT +1. The time now is 11:46 AM.

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"