By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,478 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,478 IT Pros & Developers. It's quick & easy.

Programtically create mdw file

P: n/a
Having nothing better to do today, I decided to do something that apparently
only Michael Kaplan knows how to do (and cannot disclose due to legal
reasons).
My method is really nothing more than a stupid cheat, embedding the whole
binary contents of the file in vba code, but who needs more? It seems to
create the file quickly and reliably and avoids using an OLE field in a
table to do this (which some people don't like). Apart from the slightly
large module size, I can't see any reason to avoid this method. Does anyone
care to comment?
Public Function CreateWorkgroup(strPath As String) As Boolean

On Error GoTo Err_Handler

Dim a(0 To 3327) As String
Dim lngCount As Long
Dim strData As String
Dim intFile As Integer

a(0) =
"000100004A65742053797374656D20444220200001000000B 56E03626009C255"
a(1) =
"E9A96772403F009C7E9F90FF859A31C57FBAED30BBDFCC9D6 3D9E4C39F46AE38"
a(2) =
"4BEE7A6DEC37A1D29CFA3AC828E6EF208A60A8027B3609E4D FB18B6213433339"

<snip><snip><snip><snip><snip><snip>

a(3327) =
"6A2EED6AD8861A1B71052B9CFACCE699FC170E04EC32CD1D8 55E70B4CF6E38D7"

For lngCount = 0 To 3327
strData = strData & ConvertHex(a(lngCount))
Next lngCount

intFile = FreeFile

Open strPath For Binary As intFile

Put intFile, , strData

Close intFile

CreateWorkgroup = True

Exit_Handler:
Exit Function

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function

Private Function ConvertHex(strCode As String) As String

Dim lngPos As Long
Dim strData As String
Dim str As String

If Len(strCode) > 1 Then
If Len(strCode) Mod 2 = 0 Then
lngPos = 1
Do While lngPos < Len(strCode)
strData = strData & Chr$(CLng("&H" & Mid$(strCode, lngPos,
2)))
lngPos = lngPos + 2
Loop
End If
End If

ConvertHex = strData

End Function
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Thu, 27 Oct 2005 11:03:11 +0000 (UTC), "Brian Wilson"
<bw*****@ease.co.uk> wrote:

Not sure what problem you're trying to solve. I would simply ship the
MDW file with my application.
-Tom.

Having nothing better to do today, I decided to do something that apparently
only Michael Kaplan knows how to do (and cannot disclose due to legal
reasons).
My method is really nothing more than a stupid cheat, embedding the whole
binary contents of the file in vba code, but who needs more? It seems to
create the file quickly and reliably and avoids using an OLE field in a
table to do this (which some people don't like). Apart from the slightly
large module size, I can't see any reason to avoid this method. Does anyone
care to comment?
Public Function CreateWorkgroup(strPath As String) As Boolean

On Error GoTo Err_Handler

Dim a(0 To 3327) As String
Dim lngCount As Long
Dim strData As String
Dim intFile As Integer

a(0) =
"000100004A65742053797374656D20444220200001000000 B56E03626009C255"
a(1) =
"E9A96772403F009C7E9F90FF859A31C57FBAED30BBDFCC9D 63D9E4C39F46AE38"
a(2) =
"4BEE7A6DEC37A1D29CFA3AC828E6EF208A60A8027B3609E4 DFB18B6213433339"

<snip><snip><snip><snip><snip><snip>

a(3327) =
"6A2EED6AD8861A1B71052B9CFACCE699FC170E04EC32CD1D 855E70B4CF6E38D7"

For lngCount = 0 To 3327
strData = strData & ConvertHex(a(lngCount))
Next lngCount

intFile = FreeFile

Open strPath For Binary As intFile

Put intFile, , strData

Close intFile

CreateWorkgroup = True

Exit_Handler:
Exit Function

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function

Private Function ConvertHex(strCode As String) As String

Dim lngPos As Long
Dim strData As String
Dim str As String

If Len(strCode) > 1 Then
If Len(strCode) Mod 2 = 0 Then
lngPos = 1
Do While lngPos < Len(strCode)
strData = strData & Chr$(CLng("&H" & Mid$(strCode, lngPos,
2)))
lngPos = lngPos + 2
Loop
End If
End If

ConvertHex = strData

End Function


Nov 13 '05 #2

P: n/a
"Tom van Stiphout" <no*************@cox.net> wrote in message
news:35********************************@4ax.com...
On Thu, 27 Oct 2005 11:03:11 +0000 (UTC), "Brian Wilson"
<bw*****@ease.co.uk> wrote:

Not sure what problem you're trying to solve. I would simply ship the
MDW file with my application.
-Tom.


Just passing the time of day as I'm "between contracts" (I think that is the
term they use). Anyway I was searching the archives and found other people
asking the same question - and it crossed my mind that if someone did
actually need to create a workgroup file programatically, then it could be
done using only vba code although other people have stated it is not
possible.
I realise that the technique is not rocket science, but it is a general
method which might prove useful to someone who wanted to make any small
binary automagically appear. So provided the user had not deleted the
mdb/mde itself, then it could restore from scratch a number of small
binaries such as icons, images or perhaps Word templates. However, as you
see, I have not been bombarded with responses, so perhaps no-one else can
see a use for the technique.
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.