Solved

creating a GUID in excel

Posted on 2012-03-22
3
3,969 Views
Last Modified: 2012-04-01
Hello All-
I want to generate in a cell a GUID for the excel file. However, it cannot change every time you open/ close it. It would be a once and done deal. So re opening it to make some edits, keeps the GUID the same.

It has to do with SSIS package I built, and in order for the DB to update the already imported fields, I need something unique that won't change each time you open the file up on the client side.

Any Ideas...Thanx
0
Comment
Question by:BKennedy2008
  • 2
3 Comments
 
LVL 7

Expert Comment

by:tipsybroom
ID: 37754159
try this:

Public Sub TestGetGUID() 
    MsgBox GetGUID, vbInformation, "GUID Generated" 
End Sub 
 
Public Function GetGUID() As String 
    GetGUID = Mid$(CreateObject("Scriptlet.TypeLib").GUID, 2, 36) 
End Function 

Open in new window


or this:

Public Type TYP_GUID
            bytes(15) As Byte
End Type
 
Public Declare Function CoCreateGuid Lib "OLE32.dll" _
                       (Guid As TYP_GUID) As Long
Public Declare Function StringFromGUID2 Lib "OLE32.dll" _
                       (Guid As TYP_GUID, _
                        ByVal lpszString As String, _
                        ByVal iMax As Long) As Long
 
Public Function CreateGUID() As String

    Dim uGuid   As TYP_GUID
    Dim sBuffer As String
    Dim lResult As Long
 
    sBuffer = VBA.Space(78)
    CoCreateGuid uGuid
    lResult = StringFromGUID2(uGuid, sBuffer, Len(sBuffer))
    CreateGUID = _
    Left$(StrConv(sBuffer, vbFromUnicode), lResult - 1)
 
End Function

Open in new window

0
 

Accepted Solution

by:
BKennedy2008 earned 0 total points
ID: 37754363
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Q_22542230.html

I found pretty much exactly what I was looking for here, but thanks tips
0
 

Author Closing Comment

by:BKennedy2008
ID: 37792672
found in another spot
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now