Thanks for replying. I'm new to macro and I'm having a problem opening it. Here's my code below and the error I'm getting is "Main() Error -2147352573 - Unable to run the specified macro". Tell me if it's right. Thanks.
Application.Run MacroName:="Fumiguide Report.AutoNew.Main"
I inserted the code in my Main Function:
Sub Main()
'**************************************************************
' DESCRIPTION
' This subroutine is the first sub that will be called by
' the macro
'
' PARAMETERS
' NONE
'
' RETURNS - None
'
' REVISION LOG
' DATE NAME CHANGE
' May 2, 2003 Joseph Manyaga Initial Revision
'**************************************************************
Dim sFileName As String
Dim sLine As String
Dim arrHeading As Variant
Dim sArea As udtAreaInfo
Dim bSuccess As Boolean
Dim arrFields As Variant
Dim arrFieldValues As Variant
Dim nCount As Integer
'These are the conversion factors
Dim dVolumeFactor As Double
Dim dTemperatureFactor As Double
Dim dWeightFactor As Double
Dim sErrorString As String
Const FUNCTION_NAME = "Main()"
On Error GoTo Error_Handler
bSuccess = False
bNoDosage = True
'Application.Run MacroName:="Normal.AutoNew.Main"
Application.Run MacroName:="Fumiguide Report.AutoNew.Main"
'Get the file name via the File Open dialog box
sFileName = WordApplicationGetOpenFileName("*.txt", True, True)
If sFileName = "" Or Right(sFileName, 1) = "\" Then
'User did not select any file, ergo abort!!!
Exit Sub
End If
'Open the file
nFileNum = FreeFile
Open sFileName For Input As #nFileNum
frmUnitOptions.Show
'Initialize the units
If bIsMetric Then
sVolumeUnit = " cu m"
sTemperatureUnit = "°C"
sCTUnit = " g-hr/cu m"
sWeightUnit = " kg"
sConcUnit = " g/cu m"
sTimeUnit = " hrs"
Else
sVolumeUnit = " cu ft"
sTemperatureUnit = "°F"
sCTUnit = " oz-hr/MCF"
sWeightUnit = " lbs"
sConcUnit = " oz/MCF"
sTimeUnit = " hrs"
End If
'Loop through the file while it is not end-of-file
Do
'Get the next line
Line Input #nFileNum, sLine
'I use the name arrHeading because I know that we will only get the
'section heading in this line.
arrHeading = MySplit(sLine, vbTab)
'If the value is not blank and contains only a single value, then
'this is a section header.
If sLine <> "" And UBound(arrHeading) = 0 Then
'Now we have to determine which section we are in
Select Case sLine
Case SEC_CUSTOMER_INFO
bSuccess = DisplayCustInfo
Case SEC_JOB_INFO
bSuccess = DisplayJobInfo
If bNoDosage Then
Exit Do
End If
Case SEC_AREA_INFORMATION
bSuccess = DisplayAreaInfo
Case SEC_INTRO_PLAN
bSuccess = ReadUselessData
Case SEC_MONITOR_PLAN
bSuccess = ReadUselessData
Case SEC_INTRO_HISTORY
bSuccess = DisplayIntroductionHistory
Case SEC_MONITOR_POINT_INPUT
bSuccess = DisplayMonitoringDataInput
Case SEC_MONITOR_POINT_STATUS
bSuccess = ReadUselessData
Case SEC_AREA_STATUS
bSuccess = DisplayAreaStatus
Case SEC_JOB_PEST
bSuccess = DisplayJobPest
Case Else
'Do nothing
End Select
If Not bSuccess Then
Exit Do
End If
End If
Loop While Not EOF(nFileNum)
Close #nFileNum
If Not bSuccess Then
MsgBox "The Fumiguide Report was not created successfully.", vbCritical
Else
MsgBox "The Fumiguide Report was created successfully.", vbInformation
End If
'Go to the first field
ActiveDocument.Bookmarks("BeginCursor").Select
Exit Sub
Error_Handler:
sErrorString = FUNCTION_NAME & vbCrLf & vbCrLf & "Error: " & Err.Number & " - " & Err.Description
MsgBox sErrorString, vbCritical, "Error"
End Sub