Author Topic: Newb Question - Invalid Character  (Read 8068 times)

0 Members and 1 Guest are viewing this topic.

Josh Nieman

  • Guest
Newb Question - Invalid Character
« 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?

Arizona

  • Guest
Re: Newb Question - Invalid Character
« Reply #1 on: January 28, 2008, 12:29:11 PM »
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 :-)

Bob Wahr

  • Guest
Re: Newb Question - Invalid Character
« Reply #2 on: January 28, 2008, 12:31:34 PM »
Depending on what you're doing and what else is required to run, use F8 to step through in debug mode.

Josh Nieman

  • Guest
Re: Newb Question - Invalid Character
« Reply #3 on: January 28, 2008, 01:33:07 PM »
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.

Josh Nieman

  • Guest
Re: Newb Question - Invalid Character
« Reply #4 on: January 28, 2008, 02:38:28 PM »
With Matt's permission:

Code: [Select]
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)
« Last Edit: January 28, 2008, 02:59:16 PM by Josh Nieman »

Guest

  • Guest
Re: Newb Question - Invalid Character
« Reply #5 on: January 28, 2008, 02:43:02 PM »
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.

Josh Nieman

  • Guest
Re: Newb Question - Invalid Character
« Reply #6 on: January 28, 2008, 02:58:04 PM »
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:

Code: [Select]
ࡱ _

*
Ytx a
YP*o a
Y8 a




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,












Y8 a

 _








=
       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
iInteger C
If  Trim
i)
Se& *A Else?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
|@GlobalSpacFalse dCreatablPredeHcla
BExposeTemplateDerivBustomizD2Option


F271231C}
|@GlobalSpacFalse dCreatablPredeHcla
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 lobalSpacoFalse CreatablPredec$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      "CA qa.Docum
G For 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       "CA a.Docum
G For 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 t xtc=_Chapnge(`EUser m_InitializVMultiPa(ge1&0#Wi@cboTB

Bas
|@GlobalSpacFalse dCreatablPredeHcla
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

Y8 a
'ht
iInteger C
If  Trim
i)
Se& *A Else?
        L@[D
        L@[DVZa_L\21>


Y8 a
Y8 a
Y8 a
 _

Y8 a
Y8 a
5
5
5

 _





















 _


Guest

  • Guest
Re: Newb Question - Invalid Character
« Reply #7 on: January 28, 2008, 03:01:20 PM »
Code: [Select]
ࡱ _

*
Ytx a
YP*o a
Y8 a




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,












Y8 a

 _








=
       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
iInteger C
If  Trim
i)
Se& *A Else?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
|@GlobalSpacFalse dCreatablPredeHcla
BExposeTemplateDerivBustomizD2Option


F271231C}
|@GlobalSpacFalse dCreatablPredeHcla
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 lobalSpacoFalse CreatablPredec$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      "CA qa.Docum
G For 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       "CA a.Docum
G For 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 t xtc=_Chapnge(`EUser m_InitializVMultiPa(ge1&0#Wi@cboTB

Bas
|@GlobalSpacFalse dCreatablPredeHcla
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

Y8 a
'ht
iInteger C
If  Trim
i)
Se& *A Else?
        L@[D
        L@[DVZa_L\21>


Y8 a
Y8 a
Y8 a
 _

Y8 a
Y8 a
5
5
5

 _





















 _



^ ^ ^ ^ ^
Ummmm??!?

Josh Nieman

  • Guest
Re: Newb Question - Invalid Character
« Reply #8 on: January 28, 2008, 03:07:41 PM »
heh
yea.

S'what I thought too.  o.0


Guest

  • Guest
Re: Newb Question - Invalid Character
« Reply #9 on: January 28, 2008, 03:08:55 PM »
heh
yea.

S'what I thought too.  o.0



Hehehe... I think THIS line is your problem!  Se& *A Else?rU

Josh Nieman

  • Guest
Re: Newb Question - Invalid Character
« Reply #10 on: January 28, 2008, 03:13:24 PM »
err..

lol where is that?

Guest

  • Guest
Re: Newb Question - Invalid Character
« Reply #11 on: January 28, 2008, 03:14:31 PM »

Josh Nieman

  • Guest
Re: Newb Question - Invalid Character
« Reply #12 on: January 28, 2008, 03:17:49 PM »
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Newb Question - Invalid Character
« Reply #13 on: January 28, 2008, 03:19:23 PM »
Se& *A Else?rU

Steady fella, we don't talk like that 'round these here parts.

 :wink:
Engineering Technologist CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com http://cadanalyst.slack.com http://linkedin.com/in/cadanalyst

Guest

  • Guest
Re: Newb Question - Invalid Character
« Reply #14 on: January 28, 2008, 03:20:31 PM »
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: