Compile error hidden module: Thisworkbook

Mohamedazees

New Member
Joined
Oct 18, 2020
Messages
43
Office Version
  1. 2019
Platform
  1. Windows
Dear Sir,

I am Using Excel 2019 32 Bit version when I am running the below Code I got the error " Compile error in hidden module"
Since my VBA project is protected" I Need the resolution for this problem, Thanks is advance for your valuable Support.

The VBA code is: ( In Thisworkbook)

Private Sub Workbook_Open()
If IsEmpty(Sheet1.Range("XAM1").Value) = True Then
Range("XAM1").Value = Date

Dim Edate As Date
Edate = DateValue(Range("XAM1")) + 2
If Date > Edate Then
MsgBox " You Must Purchase to Reactivate the File.", vbExclamation, "Contact @ md71076@gmail.com or Dial +91 8015970306"
Application.DisplayAlerts = False
ThisWorkbook.Close
Application.DisplayAlerts = True
Application.Quit

Else
MsgBox " You Can Use this Trail Version for " & Edate - Date & "Day(s)", vbInformation, "Thanks for your Support"
End If

End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I think you just missed the End If for this line
If IsEmpty(Sheet1.Range("XAM1").Value) = True Then
 
Upvote 0
I would also strongly recommend you get rid of this line
VBA Code:
Application.Quit
People will not be happy if they have unsaved workbooks & your file kills Excel.
 
  • Like
Reactions: Zot
Upvote 0
I think you just missed the End If for this line
If IsEmpty(Sheet1.Range("XAM1").Value) = True Then
As per your advice I made those necessary changes in my code but still i goat an error Type Mismatch
 
Upvote 0
As per your advice I made those necessary changes in my code but still i goat an error Type Mismatch
I tried on my Excel 2016 and it works, somehow, for whatever reason :unsure:

I believe the problem is because DateValue is expecting string format but your Range("XAM1") is a date format.
Syntax for DateValue
DateValue(Date as String) or DateValue(“August 10, 2022”)

Try remove DateValue to be just like
Edate = Range("XAM1") + 2
 
Upvote 0
I tried on my Excel 2016 and it works, somehow, for whatever reason :unsure:

I believe the problem is because DateValue is expecting string format but your Range("XAM1") is a date format.
Syntax for DateValue
DateValue(Date as String) or DateValue(“August 10, 2022”)

Try remove DateValue to be just like
Edate = Range("XAM1") + 2
Thanks now it is working perfectly
 
Upvote 0

Forum statistics

Threads
1,214,848
Messages
6,121,917
Members
449,055
Latest member
KB13

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top