TheSwamp
Code Red => VB(A) => Topic started by: Josh Nieman on January 28, 2008, 11:55:13 AM
-
Ok, I understand what an invalid character is and how to avoid them, after reading the help file, but apparently I've violated this rule and I cannot find where it is. I get a compile error "Invalid Character" and it occurs within a string of jibberish that is showing the compiled code, when the error pops up, but for the life of me I cannot find what the problem is.
Is there a list of characters that are not allowed that I can search for and check one, by one, to see if I made a typo or something?
How do I go about troubleshooting this problem if I don't know where to start?
-
How do I go about troubleshooting this problem if I don't know where to start?
Josh,
Post some of the code so that we can point you in the right direction :-)
-
Depending on what you're doing and what else is required to run, use F8 to step through in debug mode.
-
Depending on what you're doing and what else is required to run, use F8 to step through in debug mode.
lol... aw heck. The first tap of the F8 yields the same results.
Let me ask Matt if he's cool with me sharing the code since it's his that I'm tinkering with.
-
With Matt's permission:
Option Explicit
Private Const strDefaultPath = "S:\Jobs\2008\"
Private Const strDWTPath = "S:\Drafting\Templates\Drawing Templates\"
Public strNewDwgPath As String
Public strTB As String
Public intSDIMode As Integer
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
If CreateJob.Value = True Then
If CheckFoldersExistance(strDefaultPath & txtFolderName.Text) = True Then
MsgBox "The project '" & TitleCase(txtFolderName.Text) & "' already exists! Please enter a different name!", vbCritical + vbOKOnly, AppTitle
frmMain.txtFolderName.Text = ""
MultiPage1.Value = 0
Exit Sub
End If
If txtFolderName <> "" Then
intSDIMode = ThisDrawing.GetVariable("SDI")
If intSDIMode = 1 Then
ThisDrawing.SetVariable "SDI", 0
CreateProject
CreateDrawings
ThisDrawing.SetVariable "SDI", intSDIMode
Else
CreateProject
CreateDrawings
End If
MsgBox "Project setup complete!", vbInformation + vbOKOnly, AppTitle
Unload Me
Else
MsgBox "You didn't enter a folder name. Please enter a valid folder name before continuing!", vbCritical + vbOKOnly, AppTitle
End If
ElseIf ExistJob.Value = True Then
If CheckFoldersExistance(strDefaultPath & txtExistFolder.Text) = False Then
MsgBox "The project '" & TitleCase(txtExistFolder.Text) & "' does not exist! Please enter a different name!", vbCritical + vbOKOnly, AppTitle
frmMain.txtExistFolder.Text = ""
MultiPage1.Value = 0
Exit Sub
End If
If txtExistFolder <> "" Then
intSDIMode = ThisDrawing.GetVariable("SDI")
If intSDIMode = 1 Then
ThisDrawing.SetVariable "SDI", 0
InsertProject
CreateDrawings
ThisDrawing.SetVariable "SDI", intSDIMode
Else
InsertProject
CreateDrawings
End If
MsgBox "Project setup complete!", vbInformation + vbOKOnly, AppTitle
Unload Me
Else
MsgBox "You didn't enter a folder name. Please enter a valid folder name before continuing!", vbCritical + vbOKOnly, AppTitle
End If
End If
End Sub
Private Sub CreateProject()
Dim strProjectPath As String
strProjectPath = strDefaultPath & TitleCase(txtFolderName.Text) & "\"
If chkFolder1.Value = True Then
CreateFolder strProjectPath & "Drawings" & "\"
strNewDwgPath = strProjectPath & "Drawings" & "\"
End If
If chkFolder2.Value = True Then CreateFolder strProjectPath & "Calculations" & "\"
If chkFolder3.Value = True Then CreateFolder strProjectPath & "Pictures" & "\"
If chkFolder4.Value = True Then CreateFolder strProjectPath & "Correspondence" & "\"
If chkFolder5.Value = True Then CreateFolder strProjectPath & "Email" & "\"
End Sub
Private Sub InsertProject()
Dim strProjectPath As String
strProjectPath = strDefaultPath & TitleCase(txtExistFolder.Text) & "\"
If chkFolder1.Value = True Then
CreateFolder strProjectPath & "Drawings" & "\"
strNewDwgPath = strProjectPath & "Drawings" & "\"
End If
If chkFolder2.Value = True Then CreateFolder strProjectPath & "Calculations" & "\"
If chkFolder3.Value = True Then CreateFolder strProjectPath & "Pictures" & "\"
If chkFolder4.Value = True Then CreateFolder strProjectPath & "Correspondence" & "\"
If chkFolder5.Value = True Then CreateFolder strProjectPath & "Email" & "\"
End Sub
Private Sub CreateDrawings()
Dim fso As FileSystemObject
Dim objUtil As Object
Dim varPnt As Variant
Dim dblX As Double
Dim dblAngle As Double
Dim objLayout As AcadLayout
dblAngle = CDbl(0 / 180 * (Atn(1) * 4))
Set objUtil = ThisDrawing.Utility
objUtil.CreateTypedArray varPnt, vbDouble, 0#, 0#, 0#
dblX = CDbl(1#)
Set fso = New FileSystemObject
fso.CopyFile strDWTPath & cboTB.Text & ".dwg", strNewDwgPath & cboTB.Text & ".dwg", True
strTB = cboTB.Text
If chkDwg1.Value = True Then
fso.CopyFile strDWTPath & "C-01.dwt", strNewDwgPath & "C-01.dwg", True
Application.Documents.Open strNewDwgPath & "C-01.dwg"
For Each objLayout In ThisDrawing.Layouts
If objLayout.Name <> "Model" Then
ThisDrawing.ActiveLayout = ThisDrawing.Layouts(objLayout.Name)
ThisDrawing.PaperSpace.AttachExternalReference strNewDwgPath & strTB & ".dwg", strTB, varPnt, dblX, dblX, dblX, dblAngle, True
End If
Next objLayout
Application.ActiveDocument.Close True
End If
If chkDwg2.Value = True Then
fso.CopyFile strDWTPath & "S-01.dwt", strNewDwgPath & "S-01.dwg", True
Application.Documents.Open strNewDwgPath & "S-01.dwg"
For Each objLayout In ThisDrawing.Layouts
If objLayout.Name <> "Model" Then
ThisDrawing.ActiveLayout = ThisDrawing.Layouts(objLayout.Name)
ThisDrawing.PaperSpace.AttachExternalReference strNewDwgPath & strTB & ".dwg", strTB, varPnt, dblX, dblX, dblX, dblAngle, True
End If
Next objLayout
Application.ActiveDocument.Close True
End If
If chkDwg3.Value = True Then
fso.CopyFile strDWTPath & "S-02.dwt", strNewDwgPath & "S-02.dwg", True
Application.Documents.Open strNewDwgPath & "S-02.dwg"
For Each objLayout In ThisDrawing.Layouts
If objLayout.Name <> "Model" Then
ThisDrawing.ActiveLayout = ThisDrawing.Layouts(objLayout.Name)
ThisDrawing.PaperSpace.AttachExternalReference strNewDwgPath & strTB & ".dwg", strTB, varPnt, dblX, dblX, dblX, dblAngle, True
End If
Next objLayout
Application.ActiveDocument.Close True
End If
If chkDwg4.Value = True Then
fso.CopyFile strDWTPath & "A-01.dwt", strNewDwgPath & "A-01.dwg", True
Application.Documents.Open strNewDwgPath & "A-01.dwg"
For Each objLayout In ThisDrawing.Layouts
If objLayout.Name <> "Model" Then
ThisDrawing.ActiveLayout = ThisDrawing.Layouts(objLayout.Name)
ThisDrawing.PaperSpace.AttachExternalReference strNewDwgPath & strTB & ".dwg", strTB, varPnt, dblX, dblX, dblX, dblAngle, True
End If
Next objLayout
Application.ActiveDocument.Close True
End If
Set fso = Nothing
End Sub
Private Function CreateFolder(sFolder As String) As String
Dim s As String
On Error GoTo ErrorHandler
s = GetPathOnly(sFolder)
If Dir(s, vbDirectory) = "" Then
s = CreateFolder(s)
MkDir s
End If
CreateFolder = sFolder
Exit Function
ErrorHandler:
Exit Function
End Function
Private Function GetPathOnly(sPath As String) As String
GetPathOnly = Left(sPath, InStrRev(sPath, "\", Len(sPath)) - 1)
End Function
Private Sub MultiPage1_Change()
End Sub
Private Sub UserForm_Initialize()
MultiPage1.Value = 0
With cboTB
.AddItem "X-TB-CASE"
.AddItem "X-TB-MI-Swaco"
.AddItem "X-TB-ToddBroussard"
.AddItem "X-TB-RogerMcChargue"
.ListIndex = 0
End With
End Sub
First text box = txtFolderName
Second text box = txtExistFolder
First OptionButton = CreateJob
Second OptionButton = ExistJob
(edit... updated text box names... forgot the 'txt's)
-
For starters....
The original ENTER THE PROJECT NAME textbox was called txtFolderName. That apparently no longer exists, am I correct?
Secondly, if you click on the DEBUG pull-down and select COMPILE that will show you where there is an issue with the code.
-
For starters....
The original ENTER THE PROJECT NAME textbox was called txtFolderName. That apparently no longer exists, am I correct?
Secondly, if you click on the DEBUG pull-down and select COMPILE that will show you where there is an issue with the code.
No, I still have 'txtFolderName' there. What I'm wanting it to do is do an IF/Else to check the status of my OptionButtons... if the first it True, then (runs the bit you made about creating the job folder... uneditted... all I did was wrap your code in a if/then statement) elseif the second one is true, then run the bit I made... all I did was copy yours, and instead of reading the first text box, it reads the string in the second text box. I modified the existingfoldercheck to make sure there IS a folder called 'that' already, else returns an error.
As for what I modified... your block had it running a couple blocks called "CreateProject" and "CreateDrawings" ... I have the second one doing the same, except for "CreateProject" I have "InsertProject" which does the same thing, except reads the value of "txtExistFolder" rather than "txtFolderName"
'secondly' That's when I get the error... when I click COMPILE... I'd been using that to check my errors, like if I forgot to put an "EndIf" and such. it error right off the back and returns the following:
ࡱ _
*
Ytxa
YP*oa
Y8a
Document = ThisDrawing / &H0
Package={AC9F2F90-E877-11CE-9F68-00AA00574A4F}
BaseClass = frmMain
Module = modMain
Name = "CASE_ProjectSetup"
HelpContextID = "0"
VersionCompatible32 = "393222000"
CMG = "2527E719270D2B0D2B0D2B0D2B"
DPB = "1517D729371838183818"
GC = "0507C7394728482848D7"
[Host Extender Info]
&H00000001={3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000
[Workspace]
ThisDrawing=0, 0, 0, 0, C
frmMain=37, 42, 1193, 572, , 1172, 15, 1561, 433,
modMain=0, 538, 1158, 1086,
Y8a
_
=
lI
0046
.`M
_
strDWTPath8,
strNewDwgPath
intSDIMode
chkDwg1_Click
chkDwg2_Click
chkDwg3_Click
chkDwg4_ClickWF
txtFolderNamef
MultiPage14?
CreateProject
chkFolder1ie
chkFolder2je
chkFolder3ke
chkFolder4le
chkFolder5me
strFolderName%
InsertProject
2
_
O
Pub
dVer[ V1.0]Titl]& "
`
End )tFuncChec
'ht
iIntegerC
If Trim
i)
Se& *AElse?rU
l
l
,
0
t
P
P
t
P
`
8
Pl
,
0
D
l
,
0
t
P
P
t
P
`
8
Pd
,
0
D
l
,
0
t
P
P
t
P
`
8
P\
,
0
D
l
,
0
t
P
P
t
P
`
8
PT
,
0
D
c=#
_
<
_
_
H
Bas
|@GlobalSpacFalsedCreatablPredeHcla
BExposeTemplateDerivBustomizD2Option
F271231C}
|@GlobalSpacFalsedCreatablPredeHcla
BExposeTemplateDerivBustomizD2Option
_
L@[D
L@[DVZa_L\21>
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} frmMain
Caption = "UserForm1"
ClientHeight = 4140
ClientLeft = 45
ClientTop = 435
ClientWidth = 5070
StartUpPosition = 1 'CenterOwner
TypeInfoVer = 559
End
!
_
_
_
Basx0{43
dG lobalSpacoFalseCreatablPredec$la
BExpose0TemplateDeriv
P "& Co"
OK
If
t(\& txt .Text)D Then !MsgBox "@ project
aThg Sg WDI
Eb
P
k E
You Tdn 't VfjU.Yvalid QH be
""
-Dim$
ORCalcu@qms =y3C:uPi`cture?4G??;Corppondee
5Email?)T4)fsopFileSystemObAeC$+objUtilAvarPnt;Un !QdblXDo0{T4txAngpyLayouAca>d
i,ty3$.&Ty
Qp
, 0#5
18-01 t "CAqa.Docum
GFor Each#InPMzS\u .q 3[Q1
R
%xt%AcM
su.N
7(/)?'
Sub
Priva@te Funwo n CreFo@lder(s
%+-*a G)N-hLefht(sA,@ 3R$ev"\Len)) - 1 !Sub txtc=_Chan8ge(`EUser m_InitializV
""
-Dimᙿ$
2OTV AlCalcu@sos y3C:pPicturve?4??;Corpondewg
5Email)T4#)fsorFi
ity3$.0TypedArray
Qp
, 0#5
Q18-01 t "CAa.Docum
GFor Each#In0{zS\u .q3G5
R
%
If ch
7(/)?'Paper
Sub
Private Fun@on CreFolder(s
%+-?*a G)N-hLeft(sA,@ 3HRev"\Len)) - 1 !Sub txtc=_Chapnge(`EUser m_InitializVMultiPa(ge1&0#Wi@cboTB
Bas
|@GlobalSpacFalsedCreatablPredeHcla
BExposeTemplateDerivBustomizD2Option
9
1
I
.`M
a
A
)
L@[D
a
@
D=I)ExitHB74: EVR[J>a G)N-hLeft(sAF,@o 3Rev""\}Len))0 - 1 !Su@b Userzm
_
O
Pub
dVer[ V1.0]Titl]& "
`
End )tFuncChec
Y8a
'ht
iIntegerC
If Trim
i)
Se& *AElse?
L@[D
L@[DVZa_L\21>
Y8a
Y8a
Y8a
_
Y8a
Y8a
5
5
5
_
_
-
ࡱ _
*
Ytxa
YP*oa
Y8a
Document = ThisDrawing / &H0
Package={AC9F2F90-E877-11CE-9F68-00AA00574A4F}
BaseClass = frmMain
Module = modMain
Name = "CASE_ProjectSetup"
HelpContextID = "0"
VersionCompatible32 = "393222000"
CMG = "2527E719270D2B0D2B0D2B0D2B"
DPB = "1517D729371838183818"
GC = "0507C7394728482848D7"
[Host Extender Info]
&H00000001={3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000
[Workspace]
ThisDrawing=0, 0, 0, 0, C
frmMain=37, 42, 1193, 572, , 1172, 15, 1561, 433,
modMain=0, 538, 1158, 1086,
Y8a
_
=
lI
0046
.`M
_
strDWTPath8,
strNewDwgPath
intSDIMode
chkDwg1_Click
chkDwg2_Click
chkDwg3_Click
chkDwg4_ClickWF
txtFolderNamef
MultiPage14?
CreateProject
chkFolder1ie
chkFolder2je
chkFolder3ke
chkFolder4le
chkFolder5me
strFolderName%
InsertProject
2
_
O
Pub
dVer[ V1.0]Titl]& "
`
End )tFuncChec
'ht
iIntegerC
If Trim
i)
Se& *AElse?rU
l
l
,
0
t
P
P
t
P
`
8
Pl
,
0
D
l
,
0
t
P
P
t
P
`
8
Pd
,
0
D
l
,
0
t
P
P
t
P
`
8
P\
,
0
D
l
,
0
t
P
P
t
P
`
8
PT
,
0
D
c=#
_
<
_
_
H
Bas
|@GlobalSpacFalsedCreatablPredeHcla
BExposeTemplateDerivBustomizD2Option
F271231C}
|@GlobalSpacFalsedCreatablPredeHcla
BExposeTemplateDerivBustomizD2Option
_
L@[D
L@[DVZa_L\21>
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} frmMain
Caption = "UserForm1"
ClientHeight = 4140
ClientLeft = 45
ClientTop = 435
ClientWidth = 5070
StartUpPosition = 1 'CenterOwner
TypeInfoVer = 559
End
!
_
_
_
Basx0{43
dG lobalSpacoFalseCreatablPredec$la
BExpose0TemplateDeriv
P "& Co"
OK
If
t(\& txt .Text)D Then !MsgBox "@ project
aThg Sg WDI
Eb
P
k E
You Tdn 't VfjU.Yvalid QH be
""
-Dim$
ORCalcu@qms =y3C:uPi`cture?4G??;Corppondee
5Email?)T4)fsopFileSystemObAeC$+objUtilAvarPnt;Un !QdblXDo0{T4txAngpyLayouAca>d
i,ty3$.&Ty
Qp
, 0#5
18-01 t "CAqa.Docum
GFor Each#InPMzS\u .q 3[Q1
R
%xt%AcM
su.N
7(/)?'
Sub
Priva@te Funwo n CreFo@lder(s
%+-*a G)N-hLefht(sA,@ 3R$ev"\Len)) - 1 !Sub txtc=_Chan8ge(`EUser m_InitializV
""
-Dimᙿ$
2OTV AlCalcu@sos y3C:pPicturve?4??;Corpondewg
5Email)T4#)fsorFi
ity3$.0TypedArray
Qp
, 0#5
Q18-01 t "CAa.Docum
GFor Each#In0{zS\u .q3G5
R
%
If ch
7(/)?'Paper
Sub
Private Fun@on CreFolder(s
%+-?*a G)N-hLeft(sA,@ 3HRev"\Len)) - 1 !Sub txtc=_Chapnge(`EUser m_InitializVMultiPa(ge1&0#Wi@cboTB
Bas
|@GlobalSpacFalsedCreatablPredeHcla
BExposeTemplateDerivBustomizD2Option
9
1
I
.`M
a
A
)
L@[D
a
@
D=I)ExitHB74: EVR[J>a G)N-hLeft(sAF,@o 3Rev""\}Len))0 - 1 !Su@b Userzm
_
O
Pub
dVer[ V1.0]Titl]& "
`
End )tFuncChec
Y8a
'ht
iIntegerC
If Trim
i)
Se& *AElse?
L@[D
L@[DVZa_L\21>
Y8a
Y8a
Y8a
_
Y8a
Y8a
5
5
5
_
_
^ ^ ^ ^ ^
Ummmm??!?
-
heh
yea.
S'what I thought too. o.0
-
heh
yea.
S'what I thought too. o.0
Hehehe... I think THIS line is your problem! Se& *A Else?rU
-
err..
lol where is that?
-
err..
lol where is that?
Module1
-
oh snap.
I had closed the module window and I wasn't looking there.. I was just looking at ... ok yea... thanks for the pointer!
Off to investigate.
I have no clue how that happened... I'm seriously perplexed.
-
Se& *A Else?rU
Steady fella, we don't talk like that 'round these here parts.
:wink:
-
Se& *A Else?rU
Steady fella, we don't talk like that 'round these here parts.
:wink:
You Tdn 't VfjU.Yvalid QH be
""
-Dim$
ORCalcu@qms =y3C:uPi`cture?4G??;Corppondee
5Email?)T4)fsopFileSystemObAeC$+objUtilAvarPnt;Un !QdblXDo0{T4txAngpy
:realmad:
-
... Dim$ ...
<Yosemite Sam> Dems be fightin' werds ya VB bit 'n' variant! </Yosemite Sam>
-
oh snap.
:-o
-
hahaha
great, I have made good progress.
The routine is running as expected... any errors encountered are purely because I have neglected to include something... the lines I -do- have in there work great! lol... now I just need to make sure I tell it ALL it needs to know before I tell it to run... or something...
If I don't figure it out I'll come crying, but I think I should be able to get it from here... nothing uttlery confusing for now.
-
After tinkering with this while drawing I'm now drawing a blank.
If CheckExistFoldersExistance(strDefaultPath & txtExistFolder.Text) = False Then
MsgBox "The project '" & TitleCase(txtExistFolder.Text) & "' does not exist! Please enter a different name!", vbCritical + vbOKOnly, AppTitle
frmMain.txtExistFolder.Text = ""
MultiPage1.Value = 0
Exit Sub
End If
The folder it's calling out DOES exist. It gets the value for "txtExistFolder" which is what you enter into that second text box... well I pasted the path right from windows Explorer and it's a real folder... but for some reason it's telling me "does not ext"
CheckExistFoldersExistance is:
Public Function CheckExistFoldersExistance(strExistFolder As String) As Boolean
Dim fso As FileSystemObject
Set fso = New FileSystemObject
CheckExistFoldersExistance = fso.FolderExists(strExistFolder)
Set fso = Nothing
End Function
I don't know what I'm doing, I think.
After I get this thing working right, and roll it out, I'm going to start with the basic tutorial stuff to try and get the basics down better, before attempting to tool around with this stuff.
-
Is there a slash between these two bad boys??!? Do you need to add one somewhere?!?
strDefaultPath & "\" & txtExistFolder.Text
-
I tried adding my own slash to the end of it as well, but I put your addition in, and still get it... see pic.
-
Try calling it George.
-
Or maybe there's a better way to accomplish what I want? I'm open to suggestions.
Try calling it George.
It didn't respond. :(
-
What is strDefaultPath set to? When entering an existing job, which appears to have a full path, adding the default path to it would give an error....
-
What is strDefaultPath set to? When entering an existing job, which appears to have a full path, adding the default path to it would give an error....
DING DING DING DING DING!!!
Private Const strDefaultPath = "S:\Jobs\2008\"
GAH! *slaps forehead*
Now let me try it out...
SCORE!!
WOOOHOOOOOOOOO!!!!
Now I am gonna go look up how to get it to accept wild cards or something.
All our job folders are labeled with the job number first, then the job description... such as /08125 - (Job Description)/
We generally just refer to job numbers... 08125... 08383 etc... so if I have it set that we can just enter job number... the user won't have to look up how the job desc was entered... thus if I can make the routine recognize
strDefaultPath/txtExistFolder (and) */
that it will somehow when 08125 is entered for 'txtExistFolder' return:
S:/Jobs/2008/08125 - (Job Description)
But that seems a bit chancy... have to look into that though...
...OH, and also to go back and add TABORDER